Possible Duplicate:
How do I add a delay in a JavaScript loop?
I want to send some POST
request from xmlhttp
object using javascript
without waiting for the response after some sleep. Inside a for
loop, this request is being sent. If i am sending all the request without waiting, my browser becomes not responding for a while also it is not allowed from the server side. How can i put sleep among all these POST
request?
This is what i am using-
for (var i = 0; i < users.length; i++) {
var http = new XMLHttpRequest();
//set args here, which is based elements of array users
http.open('POST', '/user/home/index.php', true);
//Set all headers here then send the request
http.send(args);
}