防止jquery ajax 重复提交

var requestSent = false;

jQuery("#buttonID").click(function() {   
   if(!requestSent) {
      requestSent = true;

      jQuery.ajax({
         url: "http://example.com",
         ....,
         timeout: timeoutValue,
         complete: function() {
             ...
             requestSent = false;
         },
      });
   }
});
posted @ 2017-08-08 22:05  会飞的小祥  阅读(133)  评论(0编辑  收藏  举报