Hey there, I'm having some trouble with XMLHttpRequest. When I call xmlhttp.send(post), the response I receive shows xmlhttp with state 1 and status 0. I understand that state 1 means the server connection is established, but why is the status showing as 0? Unfortunately, it seems like the other side isn't receiving my request.
function ajaxRequest(method, url, post, callback_fn){
var xmlhttp;
if (window.XMLHttpRequest) { //code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
} else { //code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open(method,url,true);
if (method=="POST"){
xmlhttp.setRequestHeader("Content-Type", "text/plain; charset=UTF-8");
xmlhttp.setRequestHeader("Content-Length", post.length);
}
xmlhttp.send(post);
console.log("xmlhttp.readyState = " + xmlhttp.readyState); // = 1
console.log("xmlhttp.status = " + xmlhttp.status); // = 0
}
Can anyone offer some assistance?