时间:2021-07-01 10:21:17 帮助过:29人阅读
<script language="javascript" type="text/javascript">
var xmlHttp = false;
try {
xmlHttp = new XMLHttpRequest();
} catch (trymicrosoft) {
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (othermicrosoft) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (failed) {
xmlHttp = false;
}
}
}
if (!xmlHttp)
alert("Error initializing XMLHttpRequest!");
function getCustomerInfo() {
var phone = document.getElementById("qq").value;
var url = "demo2.asp?qq=" + escape(phone);
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = updatePage;
xmlHttp.send(null);
}
function updatePage() {
if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200) {
var response = xmlHttp.responseText.split("|");
document.getElementById("message").innerHTML = '号码是:' + response[0] + '<br>姓名是:' + response[1] + '<br>性别是:' + response[2] + '<br>职务是:' + response[3];
alert("响应服务完成!");
}
else if (xmlHttp.status == 404) {
alert('请求的网址不存在!');
}
else {
alert('错误:错误代码为:' + xmlHttp.status);
}
}
}
</script>
<input id="qq" type="text" onchange="getCustomerInfo()" />
<div id="message">请尝试输入我的QQ号码:178010108,会看到返回的详细资料.</div>
服务端程序代码:
代码如下:
<%
Response.ContentType = "text/xml"
Response.CharSet = "GB2312"
if request("qq") = "178010108" then
response.write "178010108|阿里西西|男|ASP技术"
else
response.write "这个QQ号码是空号哦"
end if
%>