[英]Problem with my Javascript Code
谁能告诉我为什么此代码不起作用? 我什至无法获得alert(); 在init()中正确工作...
window.onload = init;
var downloadedstuff;
function init() {
alert();
$.get('example.php' + '?v=' + Math.random(), success: function (data) {
downloadedstuff = data;
});
doTimer();
}
var t;
var timer_is_on=0;
function timedCount()
{
$.get('example.php' + '?v=' + Math.random(), success: function (data) {
if(data != downloadedstuff)
{
alert('SOMETHING HAPPENED!!!!');
location.reload(true);
}
else
{
alert(data);
}
});
t=setTimeout("timedCount()",5000);
}
function doTimer()
{
if (!timer_is_on)
{
timer_is_on=1;
timedCount();
}
}
再次对所有问题深表歉意,我只是不知道怎么了。
此行(发生两次):
$.get('example.php' + '?v=' + Math.random(), success: function(data) {
应该:
$.get('example.php' + '?v=' + Math.random(), function(data) {
因为:
是用于javascript对象
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.