I want to poll the data from the WebServer(PHP) at an interval of 15 seconds, for 50 to 100 times (or lets say infinite loop, until the stopFlag variable is set to true.).
For this data polling, i am going to use the AJAX ASYNC message for sending the requests to the WebServer.
How can i achieve this?
I have tried to solve this puzzle by myself, but unfortunatly, i failed as there is no keyword for pausing the script execution in the javascript.
Is there any way to make it work? or any workaround on this? Kindly let me know or share your experience if you have already faced this issue.
I want to poll the data from the WebServer(PHP) at an interval of 15
Share
You have to use a callback for the timeout; it will recursively call the next function.
You can also use jQuery which can help you to make your code more compact. The result might look something like this:
And in params you would have a success function like this:
Just call keepTrying() the first time; it will loop until it is successful. This code is a bit ugly but hopefully you get the idea.