From 66c89add39b8b0a2db6a44fed5fb7211f9f9d614 Mon Sep 17 00:00:00 2001 From: jlukic Date: Thu, 23 Jul 2015 15:46:22 -0400 Subject: [PATCH] Clean up logic in onComplete for cogency #2713 --- src/definitions/behaviors/api.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/definitions/behaviors/api.js b/src/definitions/behaviors/api.js index d210e8a9f..401d6f9a2 100644 --- a/src/definitions/behaviors/api.js +++ b/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); },