<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="Scripts/jquery-1.10.2.intellisense.js"></script>
<script type="text/javascript">
$(function () {
// alert(1);
$('a')[0].onclick = function () {
if (xhr.readyState == 4) {
if (xhr.status == 200 || xhr.status == 304) {
alert(xhr.responseText);
}
}
}
return false;
}
})
</script>
</head>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Test</title>
// 引入js
<script src="Scripts/jquery-1.10.2.intellisense.js"></script>
<script type="text/javascript">
$(function () {
// alert(1);
$('a')[0].onclick = function () {
// alert(1);
//新建XMLHttpRequest对象
var xhr = new XMLHttpRequest();
// 请求方式
var method = "GET";
//请求地址
var url = this.href;
//open 方法
xhr.open(method, url);
//send
xhr.send(null);
//状态检查员
if (xhr.readyState == 4) {
if (xhr.status == 200 || xhr.status == 304) {
alert(xhr.responseText);
}
}
}
return false;
}
})
</script>
</head>
<body>
// 页面内容
</body>
</html>