QML fetch file from server code example

Example: ajax request qml

function makeRequest()
{

    var doc = new XMLHttpRequest();
    msg.text = "";
    doc.onreadystatechange = function() {
        if (doc.readyState == XMLHttpRequest.HEADERS_RECEIVED) {
            showRequestInfo("Headers -->");
            showRequestInfo(doc.getAllResponseHeaders ());
            showRequestInfo("Last modified -->");
            showRequestInfo(doc.getResponseHeader ("Last-Modified"));

        } else if (doc.readyState == XMLHttpRequest.DONE) {
            var a = doc.responseXML.documentElement;
            for (var ii = 0; ii < a.childNodes.length; ++ii) {
                showRequestInfo(a.childNodes[ii].nodeName);
            }
            showRequestInfo("Headers -->");
            showRequestInfo(doc.getAllResponseHeaders ());
            showRequestInfo("Last modified -->");
            showRequestInfo(doc.getResponseHeader ("Last-Modified"));
        }
    }

    doc.open("GET", "data.xml");
    doc.send();
}