mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 18:17:20 +00:00
Http utilities: add xhr object to callback
This commit is contained in:
parent
04a4a0f92e
commit
232eba2f7d
@ -17,7 +17,7 @@ A quick and dirty HTTP function; to be refactored later. Options are:
|
|||||||
url: URL to retrieve
|
url: URL to retrieve
|
||||||
headers: hashmap of headers to send
|
headers: hashmap of headers to send
|
||||||
type: GET, PUT, POST etc
|
type: GET, PUT, POST etc
|
||||||
callback: function invoked with (err,data)
|
callback: function invoked with (err,data,xhr)
|
||||||
returnProp: string name of the property to return as first argument of callback
|
returnProp: string name of the property to return as first argument of callback
|
||||||
*/
|
*/
|
||||||
exports.httpRequest = function(options) {
|
exports.httpRequest = function(options) {
|
||||||
@ -48,7 +48,7 @@ exports.httpRequest = function(options) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Something went wrong
|
// Something went wrong
|
||||||
options.callback($tw.language.getString("Error/XMLHttpRequest") + ": " + this.status);
|
options.callback($tw.language.getString("Error/XMLHttpRequest") + ": " + this.status,null,this);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// Make the request
|
// Make the request
|
||||||
@ -67,7 +67,7 @@ exports.httpRequest = function(options) {
|
|||||||
try {
|
try {
|
||||||
request.send(data);
|
request.send(data);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
options.callback(e);
|
options.callback(e,null,this);
|
||||||
}
|
}
|
||||||
return request;
|
return request;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user