2011-09-10 9 views
0

誰でもこのコードが動作しない理由を教えてください。私はアラートを得ることさえできません()。 init()ですべての質問に対して、本当に申し訳ありませんが、もう一度...私のJavascriptコードに問題があります

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(); 
    } 
} 

を正しく動作するために、私は間違っているのか分かりません。

+0

オブジェクトjavascriptのためのものですので、は()のようにエラーが発生しますアラートにはパラメータとして文字列が必要です。 – Eineki

+0

IE9ではなく、少なくとも、私は文字列を追加します:P – MatthewSot

答えて

4

(2回発生する)この行:

$.get('example.php' + '?v=' + Math.random(), success: function(data) { 

は次のようになります。

$.get('example.php' + '?v=' + Math.random(), function(data) { 

:アラート、あなたが知っている

+0

ああうわー...ありがとう! – MatthewSot

関連する問題