Use Jquery.more.js to achieve a click on the bottom and then load the new data at the bottom

Source: Internet
Author: User

<div class= "Bus-nav-bar ft12" > <div class= "navt bor-r-c pos-rel {if $int = = 0}fwbold{/if}" ><a href= "Port Al.php?mod=merchant&action=voucherlist&int=0 "> All orders </a><em class=" Pos-abs "></em> </div> <div class= "Navt bor-r-c pos-rel {if $int = = 7}fwbold{/if}" ><a href= "portal.php?mod=merchant& Action=voucherlist&int=7 "> Last 7 days Order </a><em class=" Pos-abs "></em></div> <div class= "NAVT Pos-rel {if $int = = 30}fwbold{/if}" ><a href= "portal.php?mod=merchant&action=voucherlist&int=30" > Last one months order </a><em class= "Pos-abs" ></em></div></div><div class= "bus94 M-0-auto" Id= "Vlist" > <ul class= "Busbox ft12" > <li class= "HEADH2" > Consumption confirmation Code: <span class= "Checkcode" ></ span></li> <li class= "HEADH2" > Electronic serial Code: <span class= "password" ></span></li> & Lt;li class= "HEADH2" > Product Name: <span class= "ProductName"></span></li> <li class= "HEADH2" > Product Price: ¥<span class= "Prices" ></span></li> <li class= "HEADH2" > Verification time: <span class= "Checktime" ></span></li> </ul> <div ID = "Get_more" class= "txtcent button ft12" > More </div></div><script type=text/javascript src= "{        Staticurl}js/mobile/jquery.more.js "></script><script type=" Text/javascript "> jquery (function () {            JQuery (' #vlist '). More ({"url": ' Portal.php?mod=ajax&do=mvoucher ', "data": {"int": "{$int}"},    "Template": ". Busbox", "Trigger": "#get_more"}); });</script>

  

PHP code

The mobile merchant has verified the voucher list    $int = intval ($_get[' int ');    $int = In_array ($int, Array (0,7,30))? $int: 0;    $params = null;    if ($int = = 7) {        $params = array (' StartTime ' =>date ("y-m-d", Strtotime (" -7days"));    } ElseIf ($int = =) {        $params = array (' StartTime ' =>date ("y-m-d", Strtotime (" -30days"));    }    $last = Intval ($_get[' last ')/5 + 1;    $data = merchant_checked_list (107, $params, 5, $last);    if ($data && $data [' data ']) {        foreach ($data [' data '] as $key + $value) {            $data [' Data '] [$key] [' Password '] = Decrypt ($value [' Password ']);            $data [' Data '] [$key] [' price '] = Deal_money ($value [' Price ']);            $data [' Data '] [$key] [' checktime '] = Date (' y-m-d h:i:s ', $value [' checktime ']);        }        Echo Json_encode ($data [' data ']);    }

Jquery.more.js

/** * Call parameters, such as: $ (' #more '). More ({' URL ': ' data.php '}); * Amount: ' 10 ' record count per display * URL: ' comments.php ' request background address * data:{}, custom parameter * Template: '. single_it          Em ' HTML record div ' class attribute * Trigger: ' #get_more ' trigger to load more records class Property * Scroll: ' false ' supports scrolling trigger load * Offset: ' 100 '    The offset at which the scrolling trigger loads */(function ($) {var target = null;    var template = null;    var lock = false;    var variables = {' Last ': 0}; var settings = {' Amount ': ' 8 ', ' url ': ', ' template ': '. Single_item ', ' data ': {}, ' trig    Ger ': ' #get_more ', ' scroll ': ' false ', ' offset ': ' 100 '};                    var methods = {Init:function (options) {return This.each (function () {if (options) {                $.extend (settings, options);                } template = $ (this). Children (settings.template). Wrap (' <div/> '). parent ();                Template.css (' Display ', ' none '); $ (this). Append(' <div class= "Loading ft12" id= "Waitbox" > Loading in:                </div> ');                $ (this). Children (settings.template). Remove ();                target = $ (this);                    if (Settings.scroll = = ' false ') {$ (this). Find (Settings.trigger). bind (' Click.more ', methods.get_data);                $ (this). More (' get_data '); } else {if ($ (this). Height () <= $ (this). attr (' scrollheight ')) {Target.more (                    ' Get_data ', Settings.amount * 2);                } $ (this). bind (' Scroll.more ', methods.check_scroll);        }            }); }, Check_scroll:function () {if (Target.scrolltop () + target.height () + parseint (settings.offset))            = Target.attr (' scrollheight ') && lock = = False) {Target.more (' get_data '); }}, Remove:function () {TArget.children (Settings.trigger). Unbind ('. more ');            Target.unbind ('. more ');        Target.children (Settings.trigger). Remove ();            }, Add_elements:function (data) {var root = target;            var counter = 0;                    if (data) {$ (data). each (function () {counter++;                    var t = template; $.each (this, function (key, value) {if (T.find ('. ' + key)) T.find ('. ' +                    Key). HTML (value);                    });                    if (Settings.scroll = = ' true ') {Root.children ('. More_loader_spinner '). Before (t.html ());                    } else {Root.children (Settings.trigger). Before (t.html ());                } root.children (Settings.template + ': Last '). attr (' id ', ' more_element_ ' + ((variables.last++) + 1));            }); } else {Methods.remove ();            } target.children ('. More_loader_spinner '). CSS (' Display ', ' none ');        if (Counter < Settings.amount) Methods.remove ();            }, Get_data:function () {var ile;            Lock = true;            Target.children (". More_loader_spinner"). CSS (' Display ', ' block ');            $ (Settings.trigger). CSS (' Display ', ' none ');            if (typeof (Arguments[0]) = = ' Number ') ile = Arguments[0];            else {ile = Settings.amount;                } var postdata = Settings.data;                Postdata[' last '] = variables.last;            postdata[' amount '] = ile;                $.post (Settings.url, PostData, function (data) {$ (Settings.trigger). CSS (' Display ', ' block ');                Methods.add_elements (data);                lock = false;            $ ("#waitbox"). Remove ();        }, ' json ');    }    };  $.fn.more = function (method) {if (Methods[method])          Return methods[Method].apply (this, Array.prototype.slice.call (arguments, 1));        else if (typeof method = = ' object ' | |!method) return methods.init.apply (this, arguments);    else $.error (' method ' + method + ' does not exist! '); }}) (JQuery)

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.