Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jio-main
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Hardik Juneja
jio-main
Commits
4516bf6e
Commit
4516bf6e
authored
Aug 29, 2013
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jIO.util.ajax added
parent
04a26788
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
1 deletion
+26
-1
src/jio/core/util.js
src/jio/core/util.js
+26
-1
No files found.
src/jio/core/util.js
View file @
4516bf6e
/*jslint indent: 2, maxlen: 80, nomen: true, sloppy: true */
/*jslint indent: 2, maxlen: 80, nomen: true, sloppy: true */
/*global exports, Blob, FileReader, Deferred, hex_sha256 */
/*global exports, Blob, FileReader, Deferred, hex_sha256
, XMLHttpRequest
*/
/**
/**
* Do not exports these tools unless they are not writable, not configurable.
* Do not exports these tools unless they are not writable, not configurable.
...
@@ -318,6 +318,31 @@ function readBlobAsBinaryString(blob) {
...
@@ -318,6 +318,31 @@ function readBlobAsBinaryString(blob) {
}
}
exports
.
util
.
readBlobAsBinaryString
=
readBlobAsBinaryString
;
exports
.
util
.
readBlobAsBinaryString
=
readBlobAsBinaryString
;
/**
* Send request with XHR and return a promise.
*
* @param {String} method The request method
* @param {String} url The url
* @param {Any} [data] The data to send
* @param {Function} [before_send] A function called just before send request.
* The first parameter of this function is the XHR object.
* @return {Promise} The promise
*/
function
ajax
(
method
,
url
,
data
,
before_send
)
{
var
xhr
=
new
XMLHttpRequest
(),
deferred
=
new
Deferred
();
xhr
.
open
(
method
,
url
,
true
);
xhr
.
responseType
=
"
blob
"
;
xhr
.
onload
=
deferred
.
resolve
.
bind
(
deferred
);
xhr
.
onerror
=
deferred
.
reject
.
bind
(
deferred
);
xhr
.
onprogress
=
deferred
.
notify
.
bind
(
deferred
);
if
(
typeof
before_send
===
'
function
'
)
{
before_send
(
xhr
);
}
xhr
.
send
(
data
);
return
deferred
.
promise
();
}
exports
.
util
.
ajax
=
ajax
;
/**
/**
* Acts like `Array.prototype.concat` but does not create a copy of the original
* Acts like `Array.prototype.concat` but does not create a copy of the original
* array. It extends the original array and return it.
* array. It extends the original array and return it.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment