Browse Source

Clean up logic in onComplete for cogency #2713

pull/2717/head
jlukic 9 years ago
parent
commit
66c89add39
1 changed files with 12 additions and 3 deletions
  1. 15
      src/definitions/behaviors/api.js

15
src/definitions/behaviors/api.js

@ -514,11 +514,20 @@ $.api = $.fn.api = function(parameters) {
}
settings.onSuccess.call(context, response, $module, xhr);
},
complete: function(maybeResponse, xhr) {
complete: function(firstParameter, secondParameter) {
var
// ajax deferred returns either response or xhr depending on success/fail
response = module.get.responseFromXHR(maybeResponse)
xhr,
response
;
// have to guess callback parameters based on request success
if( module.was.succesful() ) {
response = firstParameter;
xhr = secondParameter;
}
else {
xhr = firstParameter;
response = module.get.responseFromXHR(xhr);
}
module.remove.loading();
settings.onComplete.call(context, response, $module, xhr);
},

Loading…
Cancel
Save