2011-09-10 5 views
0

아무도이 코드가 작동하지 않는 이유를 말해 줄 수 있습니까? 나는 심지어 경고()를 얻을 수 없다; 초기화()에서 모든 질문에 대해 정말 죄송합니다, 다시 한번 ...자바 스크립트 코드에 문제가 있습니다.

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

을 마우스 오른쪽 버튼으로 작동, 난 그냥 잘못 알고하지 않습니다. (2 회 발생)

+0

이, 경고()와 같은 오류가 발생합니다 객체 경고에는 매개 변수로 문자열이 필요합니다. – Eineki

+0

적어도 IE9에는 없지만 문자열을 추가합니다. P – MatthewSot

답변

4

이 줄 :

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

가해야 다음 : 이후

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

는 자바 스크립트를 당신이 알고

+0

와우 ... 감사합니다! – MatthewSot

관련 문제