潇潇雨雨
您的问题是,这.ajax()会引发异步运行的Ajax请求。这意味着,.ajax()立即返回,非阻塞。因此,您将函数排队,但它们几乎会像您描述的那样同时触发。我认为在这不是接收.queue()Ajax请求的好地方,它更适合用于fx methods。您需要一个简单的经理。var ajaxManager = (function() { var requests = []; return { addReq: function(opt) { requests.push(opt); }, removeReq: function(opt) { if( $.inArray(opt, requests) > -1 ) requests.splice($.inArray(opt, requests), 1); }, run: function() { var self = this, oriSuc; if( requests.length ) { oriSuc = requests[0].complete; requests[0].complete = function() { if( typeof(oriSuc) === 'function' ) oriSuc(); requests.shift(); self.run.apply(self, []); }; $.ajax(requests[0]); } else { self.tid = setTimeout(function() { self.run.apply(self, []); }, 1000); } }, stop: function() { requests = []; clearTimeout(this.tid); } };}());这远非完美,我只想演示前进的道路。上面的例子可以像$(function() { ajaxManager.run(); $("a.button").click(function(){ ajaxManager.addReq({ type: 'POST', url: 'whatever.html', data: params, success: function(data){ // do stuff } }); });});