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

Added alwaysCallback setting that will be called regardless of success or failure #78

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/Scripts/jquery.fileDownload.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@ $.extend({
//
failCallback: function (responseHtml, url) { },

//
//a function to call after a file download dialog/ribbon has appeared regardless of success or failure
//Args:
// responseHtml - the html that came back in response to the file download. this won't necessarily come back depending on the browser.
// 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
//
alwaysCallback: function (responseHtml, url) { },

//
// the HTTP method to use. Defaults to "GET".
//
Expand Down Expand Up @@ -200,6 +210,10 @@ $.extend({

settings.successCallback(url);

if(settings.alwaysCallback) {
settings.alwaysCallback('', url);
}

deferred.resolve(url);
},

Expand All @@ -216,6 +230,10 @@ $.extend({
}

settings.failCallback(responseHtml, url);

if(settings.alwaysCallback) {
settings.alwaysCallback(responseHtml, url);
}

deferred.reject(responseHtml, url);
}
Expand Down