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