Sometimes we need to send a value to a page every once in a while, such as a chat room, every few seconds just like the database processing page values and retrieve, and then display in the Chat window. Or, every once in a while, check if the user's last speaking time is 2 minutes apart, and if so, the user exits. This time we'll use the HTML DOM setinterval () method.
The SetInterval () method can call a function or a calculation expression in the specified period (in milliseconds).
The SetInterval () method keeps calling the function until the clearinterval () is called or the window is closed. The ID value returned by SetInterval () can be used as an argument to the Clearinterval () method.
Grammar:
Copy Code code as follows:
SetInterval (code,millisec[, "Lang"])
Code
Necessary. The function to invoke or the code string to execute.
Millisec
Have to. The time interval, in milliseconds, between the periodic execution or invocation of code.
eg
SetInterval (function () {
host = Window.location.host
$.post ("http://+host+"/index.php/article/cpmes/ Value/1 ");
},5000);
Extended:
Clearinterval () method
The Clearinterval () method cancels the timeout set by SetInterval ().
The parameter of the Clearinterval () method must be the ID value returned by SetInterval ().
eg
The above content is this article about the jquery Ajax technology implementation interval n seconds to a certain page to pass the value the correlation introduction, hoped everybody likes.