Home Web Front-end JS Tutorial jQuery an ajax instance

jQuery an ajax instance

Oct 11, 2017 am 09:07 AM
ajax jquery Example

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>
Copy after login

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>
Copy after login

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 of this Website
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

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to get variables from PHP method using Ajax? How to get variables from PHP method using Ajax? Mar 09, 2024 pm 05:36 PM

How to get variables from PHP method using Ajax?

How to use PUT request method in jQuery? How to use PUT request method in jQuery? Feb 28, 2024 pm 03:12 PM

How to use PUT request method in jQuery?

jQuery Tips: Quickly modify the text of all a tags on the page jQuery Tips: Quickly modify the text of all a tags on the page Feb 28, 2024 pm 09:06 PM

jQuery Tips: Quickly modify the text of all a tags on the page

PHP vs. Ajax: Solutions for creating dynamically loaded content PHP vs. Ajax: Solutions for creating dynamically loaded content Jun 06, 2024 pm 01:12 PM

PHP vs. Ajax: Solutions for creating dynamically loaded content

Use jQuery to modify the text content of all a tags Use jQuery to modify the text content of all a tags Feb 28, 2024 pm 05:42 PM

Use jQuery to modify the text content of all a tags

The relationship between the number of Oracle instances and database performance The relationship between the number of Oracle instances and database performance Mar 08, 2024 am 09:27 AM

The relationship between the number of Oracle instances and database performance

PHP and Ajax: Ways to Improve Ajax Security PHP and Ajax: Ways to Improve Ajax Security Jun 01, 2024 am 09:34 AM

PHP and Ajax: Ways to Improve Ajax Security

How to tell if a jQuery element has a specific attribute? How to tell if a jQuery element has a specific attribute? Feb 29, 2024 am 09:03 AM

How to tell if a jQuery element has a specific attribute?

See all articles