我有以下代碼最終會填充表。在這一點上,我創建了一個XHR,在它的負載它將打電話給我的員工收藏過程XML功能responseXML顯示爲null即使xhr對象將其顯示爲集
EmployeeCollection.prototype.fetchXML = function(path, callback) {
var xhr = new XMLHttpRequest();
xhr.open("GET", path, true);
xhr.send();
xhr.onload = this.processXML(xhr, callback);
};
EmployeeCollection.prototype.processXML = function(xhr, callback) {
console.log(xhr); // this shows an XHR object with
// readyState: 4 and responseXML: document
console.log(xhr.responseXML); // null
}
我的問題是;如果我訪問xhr對象並展開控制檯中的節點,但是當我嘗試直接訪問xhr對象的這個屬性時,我怎麼能將responseXML看作一個文檔 - 我不能?
要調用的函數,而不是分配給它..... – epascarello