[英]Google Chrome - Failed GET ajax request
我正在開發一個網站,該網站從模板頁面加載html,然后從XML加載內容。 例如,這些在document.ready函數中調用
$.ajax({
type : "GET",
url : "template.html",
dataType : "html",
success : function(html) {
var ndoc = document.createElement('html');
ndoc.innerHTML = html;
page = $('body', ndoc);
$('body').html(page.html());
$.ajax({
type : "GET",
url : "XML/content.xml",
dataType : "xml",
success : function(xml) {
page = $(xml).find('chisiamo').find('dialogue')[0];
setupPage(page);
}
});
}
});
這在Firefox和Safari中效果很好。 但是在Chrome瀏覽器中,當我嘗試加載template.html時,出現“訪問控制不允許允許來源為null”的問題。 我怎么解決這個問題? 非常感謝你。
嘗試使用以下參數啟動Google Chrome:
google-chrome --disable-web-security --allow-file-access-from-files
您應該能夠創建Chrome Web App並在清單中設置權限,以允許其訪問從file://方案讀取文件。
您必須在清單中請求的頁面上添加權限。 也嘗試改用$ .getJSON;)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.