When you are trying to call same ajax function again and again ,then it may be possible that some calls are not acknowledged.i experienced this problem so i’m sharing this article Javascript sleep, javascript wait, javascript setTimeout with you .
Sleep function stops the executing thread for given amount of time.
for example:
we have function name
1 2 3 |
function do_ajax() { //some code } |
to solve this problem you have to insert some pause or some time interval between two or more consecutive call.to do so you can introduce javascript delay between two calls.
LIKE:
1 2 3 4 |
do_ajax(); tea_break(500); //sleep for 500 msec do_ajax(); |
here is the javascript function you can name it coffeebreak, teabreak, Javascript sleep, javascript wait, javascript setTimeout , javascript delay.
Javascript sleep, javascript wait, javascript setTimeout
1 2 3 4 5 6 7 8 |
function tea_break(msec) { var date = new Date(); var curDate = null; do { curDate = new Date(); } while(curDate – date < msec); } |
as shown in code it works on the current date/time and date/time interval you choose
Live example of this function:
[do_widget id=text-5]
You can download the copy of this example.
Download