Home > Backend Development > PHP Tutorial > jquery - How to replace the value in the page element after using $.get(getdata.php,data,success,'json') to obtain the data in the database.

jquery - How to replace the value in the page element after using $.get(getdata.php,data,success,'json') to obtain the data in the database.

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-08-29 08:50:53
Original
1188 people have browsed it

How to replace the value in the page element after using $.get(getdata.php,data,success,"json") to obtain the data in the database. Please explain the idea in detail.

Reply content:

How to replace the value in the page element after using $.get(getdata.php,data,success,"json") to obtain the data in the database. Please explain the idea in detail.

Modify nodes through the success function

Suppose you obtain the content of a certain article and display the page in a div with the id of content.

1.html

<div id="content"></div>
Copy after login

2. Return json format data in getdata.php

{
    "code": 0,
    "data": "视频中,渔夫们在得意地炫..."
}
Copy after login

3.js ajax gets data and renders the page

    $.get("/getdata.php", data, function(response) {
        var data = response.data;
        $("#content").html(data);
    }, "json");
Copy after login
Related labels:
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template