Ajax paging in PHP7 message board development

coldplay.xixi
Release: 2023-02-17 18:18:02
forward
1810 people have browsed it

php7 tutorialColumn introduces Ajax paging in message board development

Ajax paging in PHP7 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.

Tutorial Breakdown
  • 1. Definitiongotopage(){}Function
    JavaScript has function-based scope, as long as it is defined, The current page is globally available, and the identifier isgotopage.
  • 2. Ajax asynchronous operation
    The content of the previous lesson, the most important thing here is to pay attention to theGETmethod when making asynchronous requests,ajax.phpIt 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).
  • 3. JS printing datainnerHTML

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 theinnerHTMLattribute to assign the content to achieve the results we wantdocument.getElementById("list_box").innerHTML = 'Data returned by the server';

    • 4. Use of JS loopfor, traverse all page numbers and identify the current page number

    Use a selector to get all Page objectvar pageno = document.getElementsByClassName('pageno');
    Calculate the total number of page numberspageno.length
    forLoop through until matching Thepagepage 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.

    HTML codelist.php
         异步翻页+列表带搜索功能_留言板_科科分享    
    

    留言板

    LIST

    关键词:

    • 姓名: 联系方式: 内容:

    Copy after login
    Asynchronous paging codepage.php
    姓名:". $rows['name']." 联系方式:". $rows['contact']." 内容:".$rows['content'].""; } echo $list; exit;
    Copy after login
    Summary

    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!

Related labels:
source:jianshu.com
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 Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!