I have a file upload system, after clicking the download button, the file is then downloaded via AJAX. While the file is uploaded, I want to disable the click function located on the "Select Images" button. This is currently the function of clicking on the file select button:
$(document).ready(function() {
$("#file-button").click(function() {
$('#file').trigger('click');
});
});
This works fine, but I want to turn off the click function at runtime of XmlHttpRequest, and then turn on the click function again when I get a response from server 200. I tried bind()and unbind()and it works fine in Chrome, but in firefox the button cannot be on load I clicked what I want, and then after receiving a response from the server, the button is repeated, but in firefox, two file selection dialogs open simultaneously. This is because of the function above, and I bind the function again using bind(). Does anyone have any suggestions for enabling, then turn off the button without re-entering the code (function) of the click event.
Something like this would be preferable:
$('#file-button').disable();
$('#file-button').enable();
I tried on()and off()and they don't seem to work either.
source
share