Home >Web Front-end >JS Tutorial >jQuery an ajax instance

jQuery an ajax instance

一个新手
一个新手Original
2017-10-11 09:07:161312browse

Premise: AppServ has been installed on the computer

The code is as follows:

For the first page, only write HTML code:

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

For the second page, write jQuery Code

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

The above is the detailed content of jQuery an ajax instance. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn