I use the code below to wait, then do next loop:
function loop()
{
setTimeout(function()
{
process_number(a[i]);
i++;
if (i < a.length)
loop();
else
{
alert("done!");
}
}, 5000);
}
I want to change to like jQuery $.get callback function executed when get complete .
$.get("test.cgi", { name: "John", time: "2pm" },
function(data){
alert("Data Loaded: " + data);
});
function loop()
{
//where process_number executed complete, do next loop
//process_number(a[i]);
i++;
if (i < a.length)
loop();
else
{
alert("done!");
}
}
the function process_number Execution time is uncertain.
process_number(a[i]);? (and if it is irrelevant, you shouldn't have included it) and what is the first value ofi?