2012-05-06 34 views
0

我用javascript写了这段代码来显示此页面(Normal_Info.php)中的显示信息, ,但不幸的是它没有工作。如果有人可以帮助我,我会很感激Ajax代码来显示数据

<html> 
    <head> 
     <script language="javascript"> 
      function ajaxFunction() 
      { 
       return window.XMLHttpRequest ? 
        new window.XMLHttpRequest : 
        new ActiveXObject("Microsoft.XMLHTTP"); 
      } 

      function Go_there() 
      { 
       var httpObj = ajaxFunction(); 

       httpObj.open("GET","Normal_Info.php", true); 
       httpObj.send(); 
       httpObj.onreadystatechange = ChangedState() 
       { 
        if (httpObj.readyState == 4 && httpObj.status == 200) 
        { 
         document.getElementById("result").innerHTML=httpObj.responseText; 
        } 
       } 
      } 
     </script> 
    </head> 
    <body> 
     <form id=ff> 
      <input type=button value=Hi OnClick=Go_there() /> 
     </form> 
     <div id=result> 
     </div> 
    </body> 
</html> 

回答

0

我建议使用jQuery http://jquery.com/

<script src="jquery.js"></script> 
<script language="javascript"> 
$('#ff').submit(function() { 
$.ajax({ 
    url: 'ajax/test.html', 
    success: function(data) { 
    $('#result').html(data); 
    // alert('Load was performed.'); 
    } 
}); 
    }); 
    </script> 

无需点击事件

相关问题