0

我在 javascript 中编写了这段代码以在此页面 (Normal_Info.php) 中显示信息,但不幸的是它不起作用。如果有人可以帮助我,我将不胜感激

<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>
4

1 回答 1

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>

无需点击事件

于 2012-05-06T16:28:33.000 回答