One, settimeout this point to the problem
This in settimeout ("This.count ()", 1000) refers to the Window object.
The settimeout of JS is defined as
Copy Code code as follows:
Window.settimeout=function (Vcode, Imilliseconds [, Slanguage]) {
//..... Code
Return timer//Returns a marker
}
So when you pass this to settimeout (), of course, it refers to the current object window to which it belongs.
Workaround:
1, before the call settimeout save this, such as self=this; SetTimeout ("Self.count ()", 1000);
2. Use jquery's $.proxy to change this point, such as $.proxy (SetTimeout ("This.count ()"), this);
ii. incoming parameters to settimeout
Copy Code code as follows:
function init () {
var url = "<%=basepath%>fetchwater.do?method=searchrealwater&xzqh=" + "<%=xzqh%>" + "&rand=" + Math.random ();
alert (URL);
Window.settimeout (function () {searchjdwater (URL);},100);
}
The test can be passed in any parameter, either string or other type, but be careful to use the above workaround when passing in this.
Attached is a more detailed link to the SetTimeout reference method http://www.jb51.net/article/40524.htm