Skip to content

Commit

Permalink
Merge pull request #97 from sava1192/master
Browse files Browse the repository at this point in the history
Add original error from exception to failCallback function
  • Loading branch information
johnculviner committed Apr 29, 2015
2 parents c6e50e2 + e7e432e commit a128b85
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/Scripts/jquery.fileDownload.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* jQuery File Download Plugin v1.4.3
* jQuery File Download Plugin v1.4.3
*
* http://www.johnculviner.com
*
Expand Down Expand Up @@ -80,8 +80,9 @@ $.extend({
// in less than IE9 a cross domain error occurs because 500+ errors cause a cross domain issue due to IE subbing out the
// server's error message with a "helpful" IE built in message
// url - the original url attempted
// error - original error cautch from exception
//
failCallback: function (responseHtml, url) { },
failCallback: function (responseHtml, url, error) { },

//
// the HTTP method to use. Defaults to "GET".
Expand Down Expand Up @@ -117,7 +118,7 @@ $.extend({
//
//if specified it will be used when attempting to clear the above name value pair
//useful for when downloads are being served on a subdomain (e.g. downloads.example.com)
//
//
cookieDomain: null,

//
Expand All @@ -132,7 +133,7 @@ $.extend({
//It is recommended that on the server, htmlentity decoding is done irrespective.
//
encodeHTMLEntities: true

}, options);

var deferred = new $.Deferred();
Expand Down Expand Up @@ -203,7 +204,7 @@ $.extend({
deferred.resolve(url);
},

onFail: function (responseHtml, url) {
onFail: function (responseHtml, url, error) {

//remove the perparing message if it was specified
if ($preparingDialog) {
Expand All @@ -215,8 +216,8 @@ $.extend({
$("<div>").html(settings.failMessageHtml).dialog(settings.dialogOptions);
}

settings.failCallback(responseHtml, url);
settings.failCallback(responseHtml, url, error);

deferred.reject(responseHtml, url);
}
};
Expand Down Expand Up @@ -386,7 +387,7 @@ $.extend({
} else {
throw e;
}
}
}
}

if (isFailure) {
Expand All @@ -395,15 +396,15 @@ $.extend({
internalCallbacks.onFail(formDoc.body.innerHTML, fileUrl);
cleanUp(true);
}, 100);

return;
}
}
}
catch (err) {

//500 error less than IE9
internalCallbacks.onFail('', fileUrl);
internalCallbacks.onFail('', fileUrl, err);

cleanUp(true);

Expand Down Expand Up @@ -444,7 +445,7 @@ $.extend({
}
}
}

//iframe cleanup appears to randomly cause the download to fail
//not doing it seems better than failure...
//if ($iframe) {
Expand Down

0 comments on commit a128b85

Please sign in to comment.