2025-05-30 16:03:59 +02:00

28 lines
703 B
QML

import QtQuick 2.0
Item {
property string source: ""
property variant simple
property bool ready: true
onSourceChanged: {
ready = false
request(source, function (o) {
//console.log(o.responseText);
simple = eval('new Object(' + o.responseText + ')');ready = true;
});
}
function request(url, callback) {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = (function(myxhr) {
return function() {
if (myxhr.readyState === XMLHttpRequest.DONE && xhr.status == 200) {callback(myxhr);}
}
})(xhr);
xhr.open('get', url, true);
xhr.send('');
}
}