ajax的异步,与send的用法

前端之家收集整理的这篇文章主要介绍了ajax的异步,与send的用法前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

xhr = new XMLHttpRequest();

xhr.open("get","01list.ashx",true)

xhr.setRequestHeader("If-Modeified-Since",0);

xhr.onreadystatechange = function () {

if (xhr.readyState == 4 && xhr.status == 200) {

var res= xhr.responseText;

var jssArr = eval(res);//将回复过来的集合转换为数组

makeTable(jssArr);


"<a href='javascript:void(0)' aid='" + jssclass.Id + "'>删</a>

//获取删除时的ID

function del(obj)

{

var delid= obj.getAttribute("aid");

xhr = new XMLHttpRequest();

xhr.open("post","02del.ashx",true)

// xhr.setRequestHeader("If-Modeified-Since",0);

xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

xhr.onreadystatechange = function () {

if (xhr.readyState == 4 && xhr.status == 200) {

if (xhr.responseText == "ok") {

alert("删除成功");

var tr = obj.parentNode.parentNode;

tr.parentNode.removeChild(tr);

}

else {

alert("删除失败");

}

}

};

xhr.send("delid=" + delid);//send用法

alert(delid);

}

猜你在找的Ajax相关文章