<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>職務(wù)是:' + response[3];
alert("響應(yīng)服務(wù)完成!");
}
else if (xmlHttp.status == 404) {
alert('請求的網(wǎng)址不存在!');
}
else {
alert('錯誤:錯誤代碼為:' + xmlHttp.status);
}
}
}
</script>
<input id="qq" type="text" onchange="getCustomerInfo()" />
<div id="message">請嘗試輸入我的QQ號碼:178010108,會看到返回的詳細資料.</div>
服務(wù)端程序代碼:
代碼如下:
<%
Response.ContentType = "text/xml"
Response.CharSet = "GB2312"
if request("qq") = "178010108" then
response.write "178010108|阿里西西|男|ASP技術(shù)"
else
response.write "這個QQ號碼是空號哦"
end if
%>
聲明:本網(wǎng)頁內(nèi)容旨在傳播知識,若有侵權(quán)等問題請及時與本網(wǎng)聯(lián)系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com