It is possible to use XMLHttpRequest to load data from JavaScript. I have created the following two functions:
function loadJsonDataList(value, dataModel) { for (var i = 0; i < value.length; i ++) { dataModel.insert(value[i]); } return value; }
function loadData(url, onComplete) { var request = new XMLHttpRequest();
request.open("GET", url);
request.send();
request.onreadystatechange = function() {
if (request.readyState === 4 && request.status === 200) {
onComplete(JSON.parse(request.responseText));
} else {
onComplete(request.responseText);
}
};
}
You can use the functions above as follows:
function getData2()
{
console.log("Get data called");
Common.loadData("https://mywebservice/here/someFunction", getDataCallBack);
}
function getDataCallBack(dataObject)
{
console.log("Get data callback called");
Common.loadJsonDataList(dataObject, lstViewItems.dataModel);
}
Currently it seems like Qml DataSource objects are unable to load SSL web service data, however it is possible to load it manually as stated above. I will try to keep an eye on the issue and update the answer if they do eventually fix it or if another answer can explain how to use DataSource this way.