I have an ASP.NET MVC form that returns a report as a File(...) result. This means that the browser stays on the current page after the file download is triggered. Using jQuery, I would like to disable the submit button and then re-enable it after the file returns. My code already disables the button just fine, however, I'm unable to find an event to hook into that is triggered after the file returns.
Here's what I have so far:
$(document).ready(function() {
$("#downloadForm").submit(function() {
$("#cmdSubmit").attr("disabled", "disabled");
$("#uiProgress").show();
});
});
What can I add to this to trigger when the form submit returns?
You may have to complicate the process: rather than returning the File from the post, have #downloadForm post an AJAX request that returns the URL to the file. When the response is received, you can reenable your button and set document.location to the returned URL.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With