パッケージ化されたChrome Web Appを作成していて、外部 XML を解析しようとしています。XML ファイルをサーバーにダウンロードすると機能しますが、XML ファイルを Web 上の場所に変更すると機能しません。
たとえば、次のファイルにアクセスしようとしています: http://www.w3schools.com/xml/note.xml
これが私のJavaScriptコードです( HTML に注意してください):
function dashboardContent() {
html="";
xmlhttp=new XMLHttpRequest();
xmlhttp.open("GET","http://www.w3schools.com/xml/note.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
html+=xmlDoc.getElementsByTagName("to")[0].childNodes[0].nodeValue;
html+=xmlDoc.getElementsByTagName("from")[0].childNodes[0].nodeValue;
html+=xmlDoc.getElementsByTagName("body")[0].childNodes[0].nodeValue;
document.getElementById("contentArea").innerHTML=html;
}
私の Chrome Web App manifest.json ファイルでは、Cross-origin XMLHttpRequests に対する Google のマニフェスト要件に従って、アクセス許可の下に以下を配置しました。
{
"name": "BirdTrax",
"version": "0.1.1",
"description": "Birding explorer to help you plan birding trips and find recently eBirded sightings, rarities, and checklists in your area",
"icons": {
"16": "icons/helloWorld_16.png",
"128": "icons/helloWorld_128.png"
},
"app": {
"launch": {
"local_path": "main.html",
"container": "tab"
}
},
"background_page": "background.html",
"options_page": "options.html",
"permissions": [
"http://www.w3schools.com/*",
"notifications",
"unlimitedStorage"
],
"incognito": "split"
}
まだ何か不足しているかどうかはわかりませんが、コードが機能していません。提案、ヒント、アイデアはありますか?どんな助けにも本当に感謝します!!