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