Abude Abude - 4 months ago 9
jQuery Question

Avoid double submit in my form JQuery

JSfiddle : CODE

I was trying to send the info with POST; then I added this code to disable the button after submitting one time:

$('form').submit(function(){
$('input[type=submit]', this).attr('disabled', 'disabled');
return true;
});


but NOW : the button is disabled and the page is reloaded but the form is not submitting the info ... any solution please

PS: I need a general solution like the code above, my form doesn't have an id, because I need to apply this function to all my forms ....

Answer

this resolved my problem : http://stackoverflow.com/a/2830812/1436998

$(document).ready(function(){
    $("form").submit(function(){
        setTimeout(function() {
            $('input').attr('disabled', 'disabled');
            $('a').attr('disabled', 'disabled');
        }, 50);
    })
});