I am running the below javascript code in Ubuntu from Kaiosrt(Firefox OS) and getting readystate=4 ,but i am not getting the status as 200 and also the response is null.I am not getting any CORS error in Ubuntu.
I tired the same in windows as well, in Firefox WebIDE and came across the same issue i.e status=0 and response=null with CORS error in windows.
I am unable to solve this issue,it would be really helpful if some can suggest any solution for this .
<html>
<body>
<button type="button" onclick="onbtnSubmit()">LoginD</button>
<div id="demo"></div>
</body>
<script>
function onbtnSubmit() {
var data ={"id":"12345670","pass":"123456"};
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.open("POST", "https://apiurl");
xhr.send(data);
xhr.addEventListener("readystatechange", function() {
console.log("readyState="+this.readyState);
if(this.readyState === 4) {
console.log("status="+this.status);
console.log("response="+this.responseText);
document.getElementById("demo").innerHTML = this.status+" "+this.responseText;
}
});
return false;
}
</script>
</html>