六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 24|回复: 0

2.原始的Ajax的GET调用

[复制链接]

升级  61.33%

114

主题

114

主题

114

主题

举人

Rank: 3Rank: 3

积分
384
 楼主| 发表于 2013-1-23 02:48:34 | 显示全部楼层 |阅读模式
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title></title><script type="text/javascript">function createReq() {var req = false;if (window.XMLHttpRequest) { //Mozillareq = new XMLHttpRequest();} else if (window.ActiveXObject) { //IEtry { req = new ActiveXObject("Microsoft.XMLHTTP"); //IE6} catch (e) {  try { req = new ActiveXObject("MsXML2.XMLHTP");} catch (e) {alert("创建XMLHttpRequest对象失败!");}}}return req;}window.onload = function() {var req = createReq();req.open("GET", "ajax_cont.cfm?id=1", true);req.onreadystatechange = function () {if (req.readyState == 4) {if (req.status == 200) {document.getElementById("test").innerHTML = req.responseText;}}}req.send(null); }</script></head><body><div id="test">Div Test</div></body></html>
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表