我目前工作的一個項目試圖更新從我們的內部網服務器上的XML文件的網頁閱讀。做一些工作後,我想出了下面的代碼:的Javascript的XMLHttpRequest參數無效
// IE7+
if (window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest(); }
// IE6, IE5
else { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
xmlhttp.open("GET", "VerifiedUrl+XML.xml", false);
xmlhttp.send();
xmlDoc = xmlhttp.responseXML;
if (xmlDoc.getElementsByTagName("CheckBox")[0].childNodes[0].nodeValue == "True"){
document.getElementById("PartToUpdate").innerHTML = xmlDoc.getElementsByTagName("TextBox")[0].childNodes[0].nodeValue;
}
現在我測試過在我的本地這段代碼和它實際是從正確的文件讀取,顯示更新的信息,但是當我部署到內聯網,我得到一個「無效的參數」錯誤。 (XML文件本身已經部署並正確引用)。
編輯:我最近發現問題,因爲我引用的路徑顯然找不到文件本身。所以這帶來了另一個問題,有人也許能在闡明:
//When referencing a file within the same folder, it works correctly.
xmlhttp.open("GET", "Sample.xml", false);
//However, if I include the full path, it doesn't read correctly. (Double slashes to escape correctly)
xmlhttp.open("GET", "\\\\Full\\Server\\Path\\Here\\Sample.xml", false);
也許有人可以在此提供一些線索?
原來兩者都是同一出處的一部分。我找到了一個解決方法,但爲了教育目的決定更新這個問題。 – Gobbledigook