您好,欢迎来到刀刀网。
搜索
您的当前位置:首页jQuery一个ajax实例

jQuery一个ajax实例

来源:刀刀网


前提:电脑上已经安装了AppServ

代码如下:

第一个页面,只写HTML代码:

<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <title>第一个ajax</title>
</head>
<body>
<p class="comment">
 <h6>zhangsan:</h6>
 <p class="para">soft</p>
</p>
<p class="comment">
 <h6>李四:</h6>
 <p class="para">板凳</p>
</p>
<p class="comment">
 <h6>王五:</h6>
 <p class="para">地板</p>
</p>

</p>
<script src="../libs/jquery.js"></script>
</body>
</html>

第二个页面,写jQuery代码

<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <title>test</title>
</head>
<body>
<input type="button" id="send" value="Ajax获取">
<p class="comment">已有评论:</p>
<p id="resText"></p>
<script src="../libs/jquery.js"></script>
<script>
 $(function () {
 $("#send").click(function () {
 /* $("#resText").load("firstajax.html"); //将firstajax页面整个内容加在id为restext中*/
 /* $("#resText").load("firstajax.html .para"); //将firstajax页面中class为para的内容加在restext中*/
 });
 });
</script>
</body>
</html>

Copyright © 2019- gamedaodao.com 版权所有 湘ICP备2022005869号-6

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务