Which is the best way/plugin/method to prevent users launching t开发者_StackOverflowoo many xhr request by clicking many times/sequentially ( :|) on a xhr button?
i'm using jQuery.
This is what I usually do:
$("button").click(function(e){
var $this = $(this);
if(!$this.data("ajaxCall")){
var xhr = $.ajax({
options here,
complete: function(){
$this.removeData("ajaxCall");
}
});
$this.data("ajaxCall", xhr)
}
});
you could remove the click event at the start of your function, and then add the click event back.
You can disable your button.
$('.someElement').attr('disabled', 'disabled');
精彩评论