[英]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.