There is a javascript function (AJAX) that sends data and a request to the server every second, and the data from the table are sequentially returned in response. How to delay sending a response from the server, for example, set some timeout so that the response is not sent until the script waits for at least one new entry in the table. In general, you need to delay the response from the server for 25 seconds, for example ... Tried the sleep () function, but is there anything else that is suitable? Thank.
|
2 answers
In your case, you need to dig in the direction of Comet .
If laziness or no opportunity to understand, I advise you to put a delay between requests of seconds 20 and return only new data.
|
And what did not arrange sleep? You can sample the number of count records from the table, and check the specified time interval, if count has changed / increased, send data. To do this, you can use the same sleep
|