aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativexmlhttprequest/data/callbackException.qml
blob: ee1043f97f7c96842015340bb25377abc10f24e1 (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
import QtQuick 2.0

QtObject {
    id: obj
    property string url
    property string which
    property bool threw: false

    onWhichChanged: {
        var x = new XMLHttpRequest;

        x.onreadystatechange = function() {
            if (x.readyState == which) {
                obj.threw = true
                throw(new Error("Exception from Callback"))
            }
        }

        x.open("GET", url);
        x.setRequestHeader("Test-header", "TestValue");
        x.send();
    }
}