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.
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>
2. Return json format data in getdata.php
{ "code": 0, "data": "视频中,渔夫们在得意地炫..." }
3.js ajax gets data and renders the page
$.get("/getdata.php", data, function(response) { var data = response.data; $("#content").html(data); }, "json");