interval between two consecutive AJAX calls.... again with JS code this time
in my js application, consecutive ajax calls are made while running in a for loop. I am using prototype.js for AJAX calls. now if I don't call any function on onComplete event then everything is ok. but if I do so, then the function I have set in an onComplete event is invoked once or twice. rest of the time it doesn't work. the code is like the follwing:
* Moves selected options from source to destination select list.
* @param source select list, destination select list
* @return none
function moveMultipleOption(sourceListId, destListId)// single or multiple based on selection
var sourceListBox = document.getElementById(sourceListId);
var destListBox = document.getElementById(destListId);
* Calls to server through Ajax
* @param option value, option text, source table name and destination table name.
* @return none
var url = '/run.php/SelectList';
var pars = 'cmd=singleTransfer' + '&itemValue=' + i + '&textValue=' + textValue + '&sourceTableName=' + sourceTableName + '&destTableName=' + destTableName;
var myAjax = new Ajax.Request(
// CODE IN THIS FUNCTION DOES NOT ALWAYS EXECUTE.
now i have solved the problem for the time being by making a single call to ajax for the whole loop. Now my question is : what is causing this problem? Can I give time delays between two consecutive requests? My hunch is that the problem lies there.