<!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 src="../jquery-1.3.1.js"></script>
<script>
var xmlHttpReq = null;
function Ajax(){
alert("1")
if(window.ActiveXObject){
xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}else if(window.XMLHttpRequest){
xmlHttpReq = new XMLHttpRequest();
}
alert("2")
xmlHttpReq.open("GET","test.html",true);
xmlHttpReq.onreadystatechange = RequestCallBack;
xmlHttpReq.send(null);
alert("3")
}
function RequestCallBack(){
alert("4")
if(xmlHttpReq.readyState == 4){
alert("6")
if(xmlHttpReq.staus == 200){
alert("5")
document.getElementById("resText").innerHTML = xmlHttpReq.responseText;
}
}
}
</script>
</head><body>
<input type="button" value="ajax提交" onclick="Ajax();" />
<div id="tesTest"></div>
</body>
</html>
在test.html中写了helloworld 在点击本页面的时候没有反应
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ajax</title>
<script src="../jquery-1.3.1.js"></script>
<script>
var xmlHttpReq = null;
function Ajax(){
alert("1")
if(window.ActiveXObject){
xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}else if(window.XMLHttpRequest){
xmlHttpReq = new XMLHttpRequest();
}
alert("2")
xmlHttpReq.open("GET","test.html",true);
xmlHttpReq.onreadystatechange = RequestCallBack;
xmlHttpReq.send(null);
alert("3")
}
function RequestCallBack(){
alert("4")
if(xmlHttpReq.readyState == 4){
alert("6")
if(xmlHttpReq.staus == 200){
alert("5")
document.getElementById("resText").innerHTML = xmlHttpReq.responseText;
}
}
}
</script>
</head><body>
<input type="button" value="ajax提交" onclick="Ajax();" />
<div id="tesTest"></div>
</body>
</html>
在test.html中写了helloworld 在点击本页面的时候没有反应
解决方案 »
- IFrame 弹出模态窗体 关闭子窗体后刷新问题 ....
- php文件中显示js文件中的某个变量的值
- 有什么办法可以跨域进行大量数据提交?
- 像ie浏览器主页的那种像select的下拉式的按钮怎么用html和js写出来
- 这个东西怎么实现?点input框,然后再弹出来的列表选择
- javascript联动有没有框架啊
- 大家来帮帮我,实在是很妖的问题,jsp中println输出有值,但是javascript弹出的是今天的日期(小弟是新手,多多关照)
- 如何在table中锁定列?多谢各位.
- if (event.srcElement.tagName=="TD")什么意思啊
- 高版本的IE存在BUG??
- 这个选项卡哪里出错了??求高手解决.
- 如何在现有表格后面添加一行?
->
if(xmlHttpReq.status == 200)
是不是../jquery-1.3.1.js引用路径的问题?
alert("1")
var xmlHttpRequest=null;
try
{
xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
xmlHttpRequest = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e2)
{
xmlHttpRequest = new XMLHttpRequest();
}
}
xmlHttpReq=xmlHttpRequest;
} 这样即使你的那个 status的错误没有改回来,代码也不会是"没有反应"的