我想通過$ .ajax()函數調用API。在FirefoxAjax響應在IE瀏覽器jquery
I'got反應,但它得到的jQuery 調試擋在IE顯示錯誤消息:
permission denied jquery-1.4.2.min.js line 127 character 287
我想通過$ .ajax()函數調用API。在FirefoxAjax響應在IE瀏覽器jquery
I'got反應,但它得到的jQuery 調試擋在IE顯示錯誤消息:
permission denied jquery-1.4.2.min.js line 127 character 287
你真的不得到一個錯誤,在IE瀏覽器,但如果你調試它,那麼你就看到服務器從未被擊中,或代碼永遠不會到達成功塊。
對於AJAX請求,www。被視爲子域,並打破xmlhttprequestobject的同源策略。
請確保您的AJAX請求中的域與頁面和您的JavaScript文件的域匹配,即您應該擺脫www。在$獲得()函數
或者,如果你仍然需要做的$不用彷徨到不同的領域,嘗試在您的jQuery(> 1.5.1)Ajax請求使用XHR選項:
$.ajax({
url: a_cross_domain_url,
type: "GET",
xhrFields: {
withCredentials: true
}
});
Hepe它會有所幫助
XHR到不同的域是不允許的? –
不默認。有一篇文章解釋爲什麼http://fettig.net/weblog/2005/11/28/how-to-make-xmlhttprequest-connections-to-another-server-in-your-domain/ – WooDzu
你是否在不同的服務器(或其他協議)上請求文件 –
發佈你用來提出請求的代碼。 –
是的,我要求對API,它在不同的服務器$阿賈克斯({ \t \t \t \t類型: 「GET」, \t \t \t網址:testUrl, \t \t \t成功:函數(MSG){ \t \t \t \t \t \t \t如果(MSG!= 「」 &&味精!= NULL){ \t \t \t \t \t \t JA lert(MSG); \t \t \t \t \t} \t \t \t}, \t \t \t錯誤:函數(){ \t \t \t \t jAlert( 「錯誤」); \t \t \t} \t \t \t}); –