mirror of
https://github.com/humhub/humhub.git
synced 2025-01-17 22:28:51 +01:00
Enh #3907: Allow client.ajax().abort()
This commit is contained in:
parent
28e1fdf337
commit
8c3b01fcf5
@ -207,6 +207,8 @@ humhub.module('client', function (module, require, $) {
|
||||
cfg = {'success': cfg};
|
||||
}
|
||||
|
||||
var requestXhr = null;
|
||||
|
||||
var promise = new Promise(function (resolve, reject) {
|
||||
cfg = cfg || {};
|
||||
|
||||
@ -255,9 +257,19 @@ humhub.module('client', function (module, require, $) {
|
||||
});
|
||||
};
|
||||
|
||||
var beforeSendHandler = cfg.beforeSend;
|
||||
var beforeSend = function (xhr, settings) {
|
||||
if(beforeSendHandler) {
|
||||
beforeSendHandler(xhr, settings);
|
||||
}
|
||||
|
||||
requestXhr = xhr;
|
||||
};
|
||||
|
||||
//Overwriting the handler with our wrapper handler
|
||||
cfg.success = success;
|
||||
cfg.error = error;
|
||||
cfg.beforeSend = beforeSend;
|
||||
cfg.url = url;
|
||||
|
||||
$.ajax(cfg);
|
||||
@ -289,6 +301,12 @@ humhub.module('client', function (module, require, $) {
|
||||
});
|
||||
};
|
||||
|
||||
promise.abort = function() {
|
||||
if(requestXhr) {
|
||||
requestXhr.abort();
|
||||
}
|
||||
};
|
||||
|
||||
return promise;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user