<html>   
<head>   
  <title>Ajax with jQuery Example</title>   
  <script type="text/JavaScript" src="jquery.js"></script>   
  <script type="text/JavaScript">   
  $(document).ready(function(){   
    $("#generate").click(function(){   
      $("#quote p").load("script.php");   
    });   
  });   
  </script>   
<style type="text/css">   
    #wrapper {   
      width: 240px;   
      height: 80px;   
      margin: auto;   
      padding: 10px;   
      margin-top: 10px;   
      border: 1px solid black;   
      text-align: center;   
    }   
  </style>   
</head>   
<body>   
  <div id="wrapper">   
    <div id="quote"><p> </p></div>   
    <input type="submit" id="generate" value="Generate!">   
  </div>   
</body>   
</html> 
代码可以在这里下载,注意你的jquery需要保存在php文件的同目录,并且名为 jquery.js .现在你已经熟悉jQuery了,让我们做些更复杂的:表单元素和XML处理,这才是真正的ajax!
1
您可能感兴趣的文章:
