mardi 4 août 2015

Block ajax script execution before the previous call succeeded

I have a button that executes an ajax function. Sometimes the server lags so maybe an user presses it more times, thinking the first time it didn't work... The main ajax function looks like this:

$.ajax({
        type: "POST",
        url: "page.php",
        dataType: "html",
        data:"data=data",
        success:  function(){
                ajax2();
                ajax3();
        }
    });

Since that ajax function updates db and makes others 2 ajax functions i need to block the button from remake the main ajax func... Only when ajax2() and ajax3() are finished, the button, if pressed, must remake the ajax function. Hope to have explained well my problem!

Aucun commentaire:

Enregistrer un commentaire