Helps you to manage AJAX requests and responses (i.e. abort requests, block requests, order requests). It is inspired by the AJAX Queue Plugin and the AjaxQueue document in the jQuery-Wiki.
Creates a new ajaxmanager and returns it. Takes a list of options:
Your constructed ajaxmanager knows the following methods:
First you have to construct/configure a new Ajaxmanager
//create an ajaxmanager named someAjaxProfileName
var someManagedAjax = $.manageAjax.create('someAjaxProfileName', {
queue: true,
cacheResponse: true
});
You have two different ways to call your methods (don´t mix them).
//and add an ajaxrequest
$.manageAjax.add('someAjaxProfileName', {
success: function(html) {
$('ul').append('<li>'+html+'</li>');
},
url: 'test.html'
});
//and add an ajaxrequest with the returned object
$.manageAjax.add({
success: function(html) {
$('ul').append('<li>'+html+'</li>');
},
url: 'test.html'
});
//create an ajaxmanager named cacheQueue
var ajaxManager = $.manageAjax.create('cacheQueue', {
queue: true,
cacheResponse: true
});
//and add an ajaxrequest with the returned object
ajaxManager.add({
success: function(html) {
$('ul').append('<li>'+html+'</li>');
},
url: 'test.html'
});
or only with the uniqueName parameter
//generate an ajaxmanger named clearQueue
$.manageAjax.create('clearQueue', {queue: 'clear', maxRequests: 2});
//and add an ajaxrequest with the name parameter
$.manageAjax.add('clearQueue', {
success: function(html) {
$('ul').append('<li>'+html+'</li>');
},
url: 'test.html'
});
Tip: Open your Firebug-Console, log the XHR´s and click around.
If you find bugs please report them!!!