ajax实现异步请求
异步请求发送按钮
var elementById = document.getElementById("button");
elementById.addEventListener("click", function (event) {
// 创建 XMLHttpRequest 对象,检测 IE5、IE6的兼容性问题
var xml_http = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
// 请求类型 URI地址 异步请求
xml_http.open("GET", "/WebSecond_war_exploded/hello", true);
// 发送请求
xml_http.send();
xml_http.onreadystatechange=function()
{
if (xml_http.readyState==4 && xml_http.status==200)
{
var responseText = xml_http.responseText;
alert(responseText);
}
}
})
标签:xml,异步,http,请求,ajax,responseText,XMLHttpRequest
来源: https://www.cnblogs.com/yumoblogs/p/14969667.html