Home>Article>Backend Development> Ajax paging in PHP7 message board development
php7 tutorialColumn introduces Ajax paging in message board development
Recommended (free):php7 tutorial
With the support of the basic page, if you want to improve the user experience of the page, asynchronous data loading is currently the best solution. way. Ajax paging is the best application scenario for practicing. The knowledge points used have been introduced to a certain extent in the previous class of Friends - PHP7 message board development (Ajax asynchronous submission). I will not describe it here. If you understand it, please read Contents of the previous section.
gotopage(){}
Functiongotopage
.GET
method when making asynchronous requests,ajax.php
It is a logical file that needs to be processed by the asynchronous request server. It only needs to receive the user's page turning request and return the data of the number of response pages (of course, content in other formats, such as JSON, will not be explained here).innerHTML
Print page turning data in the specified page area
, the style structure here is to output the content within the ul tag, so use the JS selectordocument.getElementById("list_box")
to get the ul The object of the tag, and then use theinnerHTML
attribute to assign the content to achieve the results we wantdocument.getElementById("list_box").innerHTML = 'Data returned by the server';
for
, traverse all page numbers and identify the current page numberUse a selector to get all Page objectvar pageno = document.getElementsByClassName('pageno');
Calculate the total number of page numberspageno.length
for
Loop through until matching Thepage
page number requested by the current user is the current page. If the match is successful, a style will be added to the current page number (identifying the page number for which the current request is successful).
This tutorial is based on the PHP7 message board development (pagination) content of Friends.
list.php
异步翻页+列表带搜索功能_留言板_科科分享
留言板
LIST
page.php
姓名:". $rows['name']." 联系方式:". $rows['contact']." 内容:".$rows['content'].""; } echo $list; exit;
This section is relatively difficult for novices. The knowledge points involved are a summary of what has been learned before. Before you start, you need to clarify your ideas and implement them step by step.
Remember that ideas are very important. Simply learning is not enough. You must be able to master it when you get other similar needs.
Finally, it’s time to start coding! ~
The above is the detailed content of Ajax paging in PHP7 message board development. For more information, please follow other related articles on the PHP Chinese website!