Simple code implementation loads more effects

Source: Internet
Author: User

JS <script type= "Text/javascript" >//Define global variables for pagingvar more_i = 1; $ (' #showmore '). Click (function () {$. url: ' __url__/ajax_more ',  data: Span style= "color: #000000;" > {' evalue_id ': { $evalue _info.evalue_id}, ' num ': more_i, }, DataType: ' json ', functionif (res = = 0); }else {$ (' #prev_more '). Before (res[' info ' ]); more_i = res[' num '] + 1}); }); </script>              
PHP, using the TP framework/*Ajax load More*/PublicfunctionAjax_more () {
Instantiating a model$doctor _evalue_reply = M (' doctor_evalue_reply ');
Get the data that the Ajax passes over$evalue _id =$this->_get (' evalue_id ', ' intval ');$num =$this->_get (' num ', ' intval ');
Calculate paging$start =$num * 5;//Get Data$condition [' evalue_id '] =$evalue _id;$reply _info =$doctor _evalue_reply->field (' Reply_id,user_name,content,add_time '))->where ($condition)->limit ($start. ', 5 ')->order (' Add_time desc '),Select ();If$reply _info = = =Null) {$res = 0; }Else{
The server side will return NUM Digital + + to the client JS call.$res [' num '] =$num + +;//Assemble the data into HTML,foreach ($reply _infoAs$key =$value) {$temp =$start +$key + 1;$html. = ' <tr class= '.$vlaue [' reply_id ']. ' " > ';$html. = ' <td><input name= "id[]" value= "'.$value [' reply_id ']. ' type= ' checkbox '/></td> ';$html. = ' <td> '.$temp. ' </td> ';$html. = ' <td> '.$value [' user_name ']. ' </td> ';$html. = ' <td title= '.$value [' content ']. ' " > '. MB_SUBSTR ($value [' content '],0,35, ' UTF-8 '). ' ...</td> '; $html. = ' <td> '. date (' y-m-d h:i:s ',$value [' Add_time ']). ' </td> '; $html. = ' <td><input type= "button" value= "delete" class= "button" onclick= "if (Confirm (\ ' Are you sure to remove the Doctor? \ ')") del ('. $value [' reply_id ']. '); " /></td> '; $html. = ' </tr> ';} $res [' info '] = $html;}
Returns echo Json_encode ($res) in JSON form;}

Simple code implementation loads more effects

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.