Ajax, prevent multiple request on click

前端 未结 10 2258
忘掉有多难
忘掉有多难 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:05

    for prevent multiple ajax request in whole site. For example: If use ajax request in other ajax page, Using ajax in php loop, etc, Give you multiple ajax request with one result. I have solution:

    Use window.onload = function() { ...  } 
    

    instead of

    $(document).ready(function(){ ...  });
    

    on the main index.php page. Its will be prevent all multi request. :)

提交回复
热议问题