防止jQuery中ajax重复提交
(function($){
$.oneAjax = function(settings){
if ($.oneAjax[settings.guid] === "isProcessing") {
return false;
}
$.oneAjax[settings.guid] = "isProcessing";
return $.ajax(settings).complete(function() {
delete $.oneAjax[settings.guid];
});
};
})(jQuery);
调用方式和ajax一模一样只是加了一个guid参数而已
$.oneAjax({url:'http://jquery.com',success: function(){console.log("ok")}, guid:"key1"});