Javascript XMLHttpRequest().responseText未返回完整数据

Javascript XMLHttpRequest().responseText未返回完整数据,javascript,xml,xmlhttprequest,qml,responsetext,Javascript,Xml,Xmlhttprequest,Qml,Responsetext,我使用XMLHttpRequest()从网页获取xml数据,并在XmlListModel中使用它。我遇到的问题似乎是XmlListModel使用console.log(httpReq.responseText)只获取了一小部分数据,如.responseText,它只提供了xml内部数据的20%左右 另一个问题是XmlListModel总是在一次调用之后,当我第一次调用函数时,它说fullscreen未定义,但当我再次调用它时,它就可以了。但是这个函数需要每1秒调用一次才能得到更新的数据,因为xm

我使用XMLHttpRequest()从网页获取xml数据,并在XmlListModel中使用它。我遇到的问题似乎是XmlListModel使用
console.log(httpReq.responseText)
只获取了一小部分数据,如.responseText,它只提供了xml内部数据的20%左右

另一个问题是XmlListModel总是在一次调用之后,当我第一次调用函数时,它说fullscreen未定义,但当我再次调用它时,它就可以了。但是这个函数需要每1秒调用一次才能得到更新的数据,因为xml文件总是在变化,但只有每秒钟调用一次才能得到正确的数据

函数如下所示:

XmlListModel{
    id: xmlModel
    query: "/root"
    XmlRole{ name: "fullscreen"; query: "fullscreen/string()"}
    XmlRole{ name: "volume"; query: "volume/string()"}
    XmlRole{ name: "random"; query: "random/string()"}
    XmlRole{ name: "state"; query: "state/string()"}
    XmlRole{ name: "loop"; query: "loop/string()"}
    XmlRole{ name: "repeat"; query: "repeat/string()"}
}

function getVLCstatus()
{
    var httpReq = new XMLHttpRequest()
    var url = "http://" + ip + ":" + port + "/requests/status.xml";

    httpReq.open("GET", url, true);
    // Send the proper header information along with the request
    httpReq.setRequestHeader("Authorization", "Basic " + Qt.btoa(username + ":" + password));
    httpReq.setRequestHeader('Content-Type',  'text/xml');
    httpReq.onreadystatechange = function()
    {
        if(httpReq.readyState === XMLHttpRequest.DONE)
        {
            if(httpReq.status == 200)
            {
                xmlModel.xml = httpReq.responseText
                console.log(xmlModel.get(0).fullscreen)
            }
        }
    }
    httpReq.send();
}

我做错什么了吗?

有些浏览器没有常量,比如
XMLHttpRequest.DONE
。使用数字值:

if(httpReq.readyState === 4)

如果您在此处查看是否也切断了xml的一部分,则为否:
true默认值0 3 16 1 248