2011-10-03 45 views
0

我正在通過控制檯上的http://TheScoutApp.com第3行運行此代碼我收到DOM異常11!DOM異常11

var xhr2 = new XMLHttpRequest(); 
xhr2.onreadystatechange = function() { 
    console.error(xhr2.statusText); //DOM exception 11!!! 
    if (xhr2.readyState === 4 && xhr2.status === 200) { 
    console.error('xhr2'); 
    } 
} 
xhr2.open("GET","http://thescoutapp.com/extension/update.xml",true); 
xhr2.send(); 
+0

你有什麼研究的錯誤意味着什麼?關於這個特定的錯誤還有幾個其他的問題。 –

+0

我做了...所以我接受它我想不得不如果(1 && 2) –

+2

在'onreadystatechange'之前放置'open' – epascarello

回答

4

屬性xhr.statusText只能在請求完成後才能訪問。但是,onreadystatechange回調被調用erlier-早期調用xhr.readyState == 1(=服務器連接建立)。

你必須把xhr.statusText的條件裏面的評估:

if(xhr.readyState == 4) { 
    console.error(xhr.statusText); 
} 
相關問題