原生JS的AJAX请求
//第一步,创建XMLHttpRequest对象
var xhr= new XMLHttpRequest();
function CommentAll() {
//第二步,注册回调函数
xhr.onreadystatechange =callback1;
//{
// if (xhr.readyState == 4)
// if (xhr.status == 200) {
// var responseText = xmlHttp.responseText;
// }
//}
//第三步,配置请求信息,open(),get
//get请求下参数加在url后,.ashx?methodName = GetAllComment&str1=str1&str2=str2
xhr.open("post", "/ashx/myzhuye/Detail.ashx?methodName=GetAllComment", true);
//post请求下需要配置请求头信息
//xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
//第四步,发送请求,post请求下,要传递的参数放这
xhr.send("methodName = GetAllComment&str1=str1&str2=str2");//"
}
//第五步,创建回调函数
function callback1() {
if (xhr.readyState == 4)
if (xhr.status =