i would want to know for what reason this code works on firefox, chrome and IE10, but not in IE9
var ajaxReq = new XMLHttpRequest();
var params = "name="+$('#name').val()
var url = "register.php";
ajaxReq.open("POST", url, true);
ajaxReq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
ajaxReq.setRequestHeader("Content-length",params.length);
ajaxReq.setRequestHeader("Connection", "close");
ajaxReq.onreadystatechange = function(){
if(ajaxReq.readyState == 4 && ajaxReq.status == 200)
{alert(ajaxReq.response)} //<---this results undefined
}
The code contained in php file itself doesn't matters because for do some proofs i rent it very minimal:
header('Content-Type: text/json');
echo 'response';
exit;
.response, it should be.responseTextor.responseXML- see HTTP responseJSONis a plain text format. I added this as an answer with a longer description.