I experience a weird problem in this code, actually it works for 1 second and then not anymore.. maybe some variable/function is not correctly declared and is causing this strange thing..
I have in my index.php this piece of code. If I put hardcode inside the function myfunc par1 and par2 set to zero then everything behaves correctly, means loadfunc.php is correcly called with those parameters, while if try the code I posted I see that loadfunc.php is called once correctly and so I can see the correct output for only 1 second..
<script type="text/javascript">
function myfunc(par1, par2)
{
var
$http,
$self = arguments.callee;
if (window.XMLHttpRequest) {
$http = new XMLHttpRequest();
} else if (window.ActiveXObject) {
try {
$http = new ActiveXObject('Msxml2.XMLHTTP');
} catch(e) {
$http = new ActiveXObject('Microsoft.XMLHTTP');
}
}
if ($http) {
$http.onreadystatechange = function()
{
if (/4|^complete$/.test($http.readyState)) {
document.getElementById('ReloadThis2').innerHTML = $http.responseText;
setTimeout(function(){$self();}, 1000);
}
};
$http.open('GET', 'loadfunc.php' + '?par1=' + par1 + '&par2=' + par2);
$http.send(null);
}
}
</script>
<script type="text/javascript">
setTimeout(function() {myfunc("0","0");}, 1000);
</script>
setTimeout(function(){$self();}, 1000);
重置超时,但不设置参数,这就是为什么它们显示为未定义的原因。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.