Javascript 是否存在document.implementation.createDocument()的等效项?因为这个方法在Google Chrome和Safari中返回undefined
以下代码在Firefox中运行良好,但在Google Chrome和Safari方法中Javascript 是否存在document.implementation.createDocument()的等效项?因为这个方法在Google Chrome和Safari中返回undefined,javascript,html,ajax,dom,Javascript,Html,Ajax,Dom,以下代码在Firefox中运行良好,但在Google Chrome和Safari方法中doc.documentElement.innerHTML返回未定义的。是否有其他方法可以从字符串创建文档(或将http响应转换为文档) 这有什么意义吗 这里有一些信息:啊,我看到Chrome和Safari中document.documentElement返回null,但是还有什么其他方法可以将http.responseText放入文档中(这样我就可以使用document.getElementById('foo
doc.documentElement.innerHTML
返回未定义的。是否有其他方法可以从字符串创建文档(或将http响应转换为文档)
这有什么意义吗
这里有一些信息:啊,我看到Chrome和Safari中document.documentElement返回null,但是还有什么其他方法可以将http.responseText放入文档中(这样我就可以使用document.getElementById('foo')获取数据了)
不完全是这样,我试图用返回的字符串创建一个HTML文档,而不是XML文档。现在我只做一个javascript formsubmit,而不是通过ajax请求获取数据。
var url = "/myapp/ajax";
http = getHttpObject();
http.open("POST", url, true);
http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
http.setRequestHeader("Content-length", dropdownId.length);
http.setRequestHeader("Connection", "close");
http.onreadystatechange = function() {
if(http.readyState == 4 && http.status == 200){
var doc = document.implementation.createDocument ('http://www.w3.org/1999/xhtml', 'html', null);
//This seems to return undefined
doc.documentElement.innerHTML = http.responseText;
console.log(doc);
}
}