Using jQuery Form plugin, how do I prevent form resubmission temporarily?
I'm using the jQuery Form plugin to install an event handler for form submission. However, I need to disable resubmission of the form until I receive an event that the server has finished processing. How do I do this?
$("#submit").click(function(){
$(this).attr('disabled', 'disabled');
});
will do the stuff
I solved it by introducing a JavaScript variable allowSubmit
, which is initially true
. After form submission it is false
, making my submission handler not do anything. When the server responds to the submission, allowSubmit
is reset to true
.
精彩评论