Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store jqXHR in promise object. #8145

Merged
merged 1 commit into from
Mar 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 13 additions & 4 deletions npm/packs/jquery/src/abp.jquery.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var abp = abp || {};
var abp = abp || {};
(function($) {

if (!$) {
Expand Down Expand Up @@ -99,19 +99,28 @@
options.success = undefined;
options.error = undefined;

return $.Deferred(function ($dfd) {
$.ajax(options)
var xhr = null;
var promise = $.Deferred(function ($dfd) {
xhr = $.ajax(options)
.done(function (data, textStatus, jqXHR) {
$dfd.resolve(data);
userOptions.success && userOptions.success(data);
}).fail(function (jqXHR) {
if(jqXHR.status === 0 || jqXHR.statusText === 'abort') {
//ajax request is abort, ignore error handle.
return;
}
if (jqXHR.getResponseHeader('_AbpErrorFormat') === 'true') {
abp.ajax.handleAbpErrorResponse(jqXHR, userOptions, $dfd);
} else {
abp.ajax.handleNonAbpErrorResponse(jqXHR, userOptions, $dfd);
}
});
});
}).promise();

promise['jqXHR'] = xhr;

return promise;
};

$.extend(abp.ajax, {
Expand Down