国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 開(kāi)發(fā) > AJAX > 正文

簡(jiǎn)單的ajax例子

2024-09-01 08:30:36
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友
index.asp
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>AJAX簡(jiǎn)單應(yīng)用</title>
<script language="javascript">
//創(chuàng)建XMLHttpRequest對(duì)象
var request = false;
try {
 request = new XMLHttpRequest();
} catch (trymicrosoft) {
 try {
 request = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (othermicrosoft) {
 try {
 request = new ActiveXObject("Microsoft.XMLHTTP");
 } catch (failed) {
 request = false;
 }
 }
}
if (!request)alert("Error initializing XMLHttpRequest!");
//獲取信息
function getInfo() {
 var url = "info.asp?id=" + Math.random();
 request.open("GET", url, true);
 request.onreadystatechange = updatePage;
 request.send(null);
}
//更新頁(yè)面
function updatePage() {
 if (request.readyState == 4) {
 if (request.status == 200) {
 var response = request.responseText;
 document.getElementById("div1").innerText = response;
 }else if(request.status == 404) {
 alert ("Requested URL is not found.");
 } else if (request.status == 403) {
 alert("Access denied.");
 } else
 alert("status is " + request.status);
 }
}
</script>
</head>
<body>
<input name="btn" type="button" id="btn" value="獲取" onclick="getInfo();" />
<div id="div1">此處顯示新 Div 標(biāo)簽的內(nèi)容</div>
</body>
</html>

info.asp
<%
Response.Charset = "GB2312" '不設(shè)置中文會(huì)亂碼
Dim i,arr(9)
arr(0) = "000000000000000000"
arr(1) = "11111111111111111"
arr(2) = "222222222222222222"
arr(3) = "333333333333333333"
arr(4) = "444444444444444444"
arr(5) = "555555555555555555"
arr(6) = "666666666666666666"
arr(7) = "777777777777777777"
arr(8) = "888888888888888888"
arr(9) = "999999999999999999"
Randomize
i = Int(10*Rnd())
Response.write arr(i)
%>
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 长岭县| 绵竹市| 鞍山市| 积石山| 铅山县| 平舆县| 文昌市| 泰兴市| 禄劝| 临澧县| 苏尼特左旗| 萍乡市| 天台县| 明水县| 苏尼特右旗| 遂平县| 浦城县| 千阳县| 耒阳市| 崇左市| 蒙城县| 博罗县| 哈密市| 宁国市| 建阳市| 扶沟县| 安顺市| 庄浪县| 潞城市| 高平市| 阿勒泰市| 贵南县| 塔城市| 万荣县| 阿合奇县| 榆中县| 普陀区| 兴国县| 凤庆县| 开原市| 江城|