Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/90.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 是否存在document.implementation.createDocument()的等效项?因为这个方法在Google Chrome和Safari中返回undefined_Javascript_Html_Ajax_Dom - Fatal编程技术网

Javascript 是否存在document.implementation.createDocument()的等效项?因为这个方法在Google Chrome和Safari中返回undefined

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

以下代码在Firefox中运行良好,但在Google Chrome和Safari方法中
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);
            }
        }