前提:电脑上已经安装了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>以上就是jQuery一个ajax实例的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号