jquery - Queueing ajax requests -
trying make "queue manager", can't quite wrap head around on how accomplish this. realize can disable async
, blocks , need things trigger.
my idea use callbacks or signal queue manager can let item through. have attempted multiple times , can't quite right.
this how imagine it:
mc.queuemanager = function(ajaxrequest) { var queue = []; // "queue", array this.request = ajaxrequest; queue.push(this.request); this.curtask = queue.shift() // grab , remove first item queue $.ajax({ type: "post", url: "handler.php", data: {"data": this.curtask}, success: function(data) { // handle data retrieved }, complete: function() { // so, request completed, callback if (queue.length > 0) { mc.queuemanager(queue.shift()); // grab next item , repeat } } }); };
right can understand nothing preventing multiple requests firing, can't figure out how right now. i'm looking $.deferred
in documentation. tried different method using $.when()
/ .then()
, no avail.
what setinterval(ajaxcall(), duration) method?
Comments
Post a Comment