When I try to use the following code from the sdk 3.0 emulator I get a 405 - Method Not Allowed, because XmlHttpRequest cannot load my URL - Origin Null not allowed by Access-Control-Allow-Origin ... CORS is working with identical code on other platforms , is it perhaps because the browser in the emulator treats application script domain as file:// (and sets to null) rather than localhost:// ?
I feel I must be missing something, or everyone would have the same issue ?
--------------------
function postToURL(url, process,data){
if (XHRObj !== null) {
XHRObj.destroy();
}
XHRObj = new XMLHttpRequest();
if (XHRObj)
{
console.log(\"setting up POST\");
if (XHRObj.overrideMimeType)
{
XHRObj.overrideMimeType('text/plain');
}
XHRObj.withCredentials = true;
XHRObj.open(\"POST\", url, true);
Process = process;
XHRObj.onreadystatechange = readyStateChanged;
console.log(\"object opened - \" + url);
var auth = window.btoa(LoggedInUser + \":\" + LoggedInPassword);
console.log(\"credentials encoded\");
console.log(\"Auth header is \" + auth);
XHRObj.setRequestHeader(\"Authorization\", \"Basic \" + auth);
// XHRObj.setRequestHeader(\"Access-Control-Allow-Origin\",'*');
XHRObj.setRequestHeader(\"Content-Type\", \"application/json; charset=utf-8\");
console.log(\"request header set\");
XHRObj.send(data);
}
console.log(\"XHR request processed , readyState is \" + XHRObj.readyState);
}
--------------------
