<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ajax请求</title>
<script type="text/javascript">
var xmlhttp;
var data;
//Mozilla ,chmore浏览器(将XMLHttpRequest对象作为本地浏览器对象来创建)
if(window.XMLHttpRequest){ //Mozilla 浏览器
xmlhttp = new XMLHttpRequest();
}else if(window.ActiveXObject) { //IE浏览器
//IE浏览器(将XMLHttpRequest对象作为ActiveX对象来创建)
try{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}catch(e){}
}
}
var Url = "http://ip.taobao.com/service/getIpInfo.php?ip=220.181.134.224";
xmlhttp.open("GET", Url, true);
xmlhttp.onreadystatechange = result;
xmlhttp.send(data);
function result(){
if (xmlhttp.readyState == 4) {
var response = xmlhttp.responseText;
alert(response);
}
}
</script>
</head>
<body >
<div id="Layer1" οnclick="javascript:window.location.href='demo2.html'"></div>
<H1>ajax 请求</H1>
</div>
</body>
</html>
HTML AJAX 简单数据JS
最新推荐文章于 2024-03-01 21:32:15 发布