Ajax, prevent multiple request on click

前端 未结 10 2241
忘掉有多难
忘掉有多难 2020-11-28 04:10

I\'m trying to prevent multiple requests when user click on login or register button. This is my code, but it doesn\'t work. Just the first time works fine, then return fals

10条回答
  •  暖寄归人
    2020-11-28 05:02

    I have also faced a similar problem.

    Just adding $('#do-login').attr("disabled", true); gives me the solution.

    $('#do-login').click(function(e) {
       e.preventDefault();
       $('#do-login').attr("disabled", true);
       .........
       .........
    

    Here do-login is button id.

提交回复
热议问题