In mobile development, all list items are asynchronously loaded on one page. asynchronous list items

Source: Internet
Author: User

In mobile development, all list items are asynchronously loaded on one page. asynchronous list items

During WEB development, we often encounter paging processing. If a webpage is displayed on a PC, it is acceptable to use traditional paging. Therefore, when we design interfaces for mobile phones or other mobile terminals, It is awkward and difficult to use pagination. At this time, we can load all list items on a single page. When the screen slides to the lowest end, the "click to load more" button will appear. When we click this button, more list information will be loaded to the current page. Of course, everything is asynchronous, so we use Jquery Ajax to communicate with the backend ThinkPHP Action.

Next let's take a look at the front-end code: HTML

<Div class = "row"> JavaScript:

Var p = 1;
Function more ()
{
P ++;
// Alert (p );

$. Get ('/doc/more', {'page': p, 'parameter 1': Value of parameter 1, 'parameter 2': Value of parameter 2
......}, Function (data)
{
If (data)
$ ('# BikeList'). append (data );
Else
Alert ("no more information ");
});
}

Code in ThinkPHP Action:

Public function more ($ page, $ sn, $ bk, $ fd, $ dr)
{
$ Page = $ _ GET ['page'];
$ Parameter 1 = $ _ GET ['parameter 1'];
$ Parameter 2 = $ _ GET ['parameter 2'];
......
$ Pcount = 10; // number of lists loaded each time
$ BikeList = $ this-> getbikeList (parameter 1, parameter 2 ,......, $ Page, $ pcount );
$ This-> bikeList = $ bikeList;
$ This-> display ();

}

For the sake of convenience, we have also created a view for the More function here. We don't need to write a large part of HTML. The view code More.html is as follows:

<Volist name = "bikeList" id = "vobike">
Specific list items ......
</Volist>

The HTML code output by more.html is the value of the data parameter in the previous Jquery function more. The above is my sharing of development experience. I hope to inspire you and look forward to communicating with you.

This article is first published on top search. For more information, see the source.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.