Question
Call remote twx via XMLHttpRequest will not work
Hey guys,
I have a small 2D application with a button. If I click the button the js-methode connectToTWX will call:
$scope.connectToTWX = function() {
var xhttp = new XMLHttpRequest();
var url = "http://xxxxx:8080/Thingworx/Things/RequestThing/Services/SayBla";
xhttp.setRequestHeader("Content-Type", "application/json");
xhttp.setRequestHeader("appKey", "xxxxxx");
xhttp.setRequestHeader("Accept", "application/json");
xhttp.open('POST', url, false);
xhttp.onload = function () {
if (xhttp.readyState === xhttp.DONE) {
if (xhttp.status === 200) {
console.log(xhttp.response);
console.log(xhttp.responseText);
$scope.app.params['ServiceResult'] = xhttp.responseText;
}
}
};
xhttp.send("{ }");
}
This code send a post-request to a twx server but nothing is happen. I don't get an error or something in log of the twx server. I'm not sure what happen or what can be wrong.
PS: I can request the server via Request Maker from my develope pc and this works.

