var xhr = '';
function Ajax()
{
if(window.XMLHttpRequest)
{
var xhr = new XMLHttpRequest;//现代浏览器
}else{
var xhr = new ActiveXObject('Microsoft.XMLHTTP');//IE
}
}
Ajax();//1.获取Ajax对象
xhr.onreadystatechange = function()
{
if(xhr.readyState == 4 && xhr.status == 200)
{
var data = xhr.responseText;//2.判断状态,接收数据(字符串形式),后续操作
}
}
//xhr.open('请求方式', '请求地址', TRUE);//3.异步传输连接
//xhr.send([data]);//4.发送请求
xhr.open('GET', 'demo.php?name=weichen&sex=0', TRUE);
xhr.send();