summaryrefslogtreecommitdiffstats
path: root/examples/declarative/xmlhttprequest/test.qml
blob: ef9d5f3a68cd053be6043aeac7ecfc124dce5ae1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import Qt 4.7

Rectangle {
    width: 800; height: 600

    MouseArea {
        anchors.fill: parent
        onClicked: { 

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

                    }
                }

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