<!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   在点击本页面的时候没有反应

解决方案 »

  1.   

    if(xmlHttpReq.staus == 200)
    ->
    if(xmlHttpReq.status == 200)
      

  2.   

    应该是xmlHttpReq.status 你的拼写错了
      

  3.   

    你的代码在我机器是可以执行的,点“ajax提交”可以执行ajax调用。
    是不是../jquery-1.3.1.js引用路径的问题?
      

  4.   

    为什么搂住用了Jquery却又没有用Jquery里面的ajax函数
      

  5.   

    还有你的 Ajax() 函数写错了, 你这样子写的函数只能在低版本的IE和非IE浏览器中有效,所以如果你用IE6,7之类的浏览器,是无效的,应该这样写;function Ajax(){ 
        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的错误没有改回来,代码也不会是"没有反应"的