JS <SCRIPT type = "text/JavaScript"> // defines the global variable, used to calculate the page var more_ I = 1; $ ('# showmore '). click (function () {$. ajax ({type: 'get', URL: '_ URL _/ajax_more', data: {'evalue _ id': {$ evalue_info.evalue_id}, 'num ': more_ I,}, datatype: 'json', success: function (RES) {If (RES = 0) {alert ('No More data ');} else {$ ('# prev_more '). before (RES ['info']); more_ I = res ['num'] + 1 ;},}) ;}); </SCRIPT>
PHP, using the TP framework/* ajax to load more */Public Function ajax_more (){
// Instantiate the model $ doctor_evalue_reply = m ('Doctor _ evalue_reply ');
// Obtain the data passed by Ajax. $ evalue_id = $ this-> _ Get ('evalue _ id', 'intval '); $ num = $ this-> _ Get ('num', 'intval ');
// Calculate the page $ start = $ num * 5; // obtain the 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 sends the num number ++ back to the JS client for calling. $ Res ['num'] = $ num ++; // assemble the data into HTML and foreach ($ reply_info as $ 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, 'ut F-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 you want to delete this doctor? \ ') Del ('. $ value ['reply _ id']. '); "/> </TD>'; $ HTML. = '</tr>';} $ res ['info'] = $ HTML ;}
// Return echo json_encode ($ res) in JSON format );}