Disable Button while AJAX Request

后端 未结 5 2433
旧巷少年郎
旧巷少年郎 2020-12-03 02:33

I\'m trying to disable a button after it\'s clicked. I have tried:

$(\"#ajaxStart\").click(function() {
    $(\"#ajaxStart\").attr(\"disabled\", true);
    $         


        
5条回答
  •  没有蜡笔的小新
    2020-12-03 03:23

    In your code, you just disable & enable the button on the same button click,.

    You have to enable it inside the completion of AJAX call

    something like this

               success: function(response){
                        $("#ajaxStart").attr("disabled", false); 
                           //success process here
                           $("#alertContainer").delay(1000).fadeOut(800);
                       },
    

提交回复
热议问题