XMLHttpRequest response with XmlListModel



  • I've seen several questions on this topic with no answer (that I can find).

    Basically I'm sending a request to a server which returns an XML response.

    The problem I'm having now is that with the code below I seem to get an access violation if I assign responseText to the xml property of my XmlListModel.

    Here's my code:

    @

    XmlListModel{
    id: xmlModel

      //  XmlRole { name: "type"; query: "@MODULE_TYPE/string()" }
      //  XmlRole { name: "state"; query: "@MODULE_STATE/string()" }
        
        
    
    }
    

    Button {
    id: button5
    width: 47
    height: 47
    anchors.right: parent.right
    anchors.rightMargin: 360
    anchors.top: button4.bottom
    anchors.topMargin: 20

       onClicked{
       var doc = new XMLHttpRequest();
            doc.open("POST", "http://" + ConfigPrefs.url() + "/cgi-bin/tsaws.cgi", true);
            doc.setRequestHeader('Content-Type', 'text/xml;charset=UTF-8');
            doc.send("<TSA_REQUEST_LIST PASSWORD=\"\"><TSA_REQUEST      COMMAND=\"cmdAppGetSystemStatus\"/></TSA_REQUEST_LIST>");
            doc.onreadystatechange = function(){
                if((doc.readyState == 4) && (doc.status == 200) )
                {
                    console.log(doc.responseText);
                    xmlModel.xml = doc.responseText;
                }
     }
    

    }

    @




Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.