var pendingRequests = [];
var generatePendingRequestKey = function (obj)
{
return obj.data || {};
}
$.ajaxPrefilter(function (options, originalOptions, jqXHR) {

// 不重复发送相同请求
var key = generatePendingRequestKey(options);

if (!pendingRequests[key]) {
jqXHR.pendingRequestKey = key;
pendingRequests[key] = "true";
} else {
// or do other
jqXHR.abort();
}
var complete = options.complete;
options.complete = function (jqXHR, textStatus) {
// clear from pending requests
pendingRequests[jqXHR.pendingRequestKey] = null;
if ($.isFunction(complete)) {
complete.apply(this, arguments);
}
};
});

05-08 08:06