我想知道为什么这段代码可以在 firefox、chrome 和 IE10 上运行,但不能在 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
}
php 文件中包含的代码本身并不重要,因为为了做一些证明,我租用的代码非常少:
header('Content-Type: text/json');
echo 'response';
exit;