I need to make sequential asynchronous ajax requests with limited streams. As of now I am allowed to occupy only one stream on web server so I can only do one ajax request a
As long as your callbacks are all synchronous this should work for you, if not put you on the right track
var initiateChain = function () {
var args = arguments,
index = 0,
length = args.length,
process = function ( index ) {
if ( index < length ) {
$.ajax({
url: '/example.php',
complete: function () {
// Callbacks get run here
args[ index ];
process( ++index );
}
});
}
};
if ( length ) {
process( 0 );
}
};
initiateChain( getGadgets, getDeals, getDeals );