First, Ajax requests data (using Jquery's Ajax)
Copy codeThe Code is as follows:
<Script>
$ (Function (){
$ ('# Test'). click (function (){
$. Ajax ({
Url: '_ APP _/Article/jsontest ',
Type: 'post ',
Success: function (data ){
Var item;
$. Each (data, function (I, result ){
Item = "<tr> <td>" + result ['num'] + "</td> <td>" + result ['title'] + "</td> <td> "+ result ['credate'] +" </td> <td> operation </td> </tr> ";
$ ('. Table'). append (item );
});
}
})
})
});
</Script>
The backend processes the request and returns data in Json format (Thinkphp is used)
Copy codeThe Code is as follows:
$ List = $ File-> group ('num')-> order ('Id desc')-> limit ($ Page-> firstRow. ','. $ Page-> listRows)-> select ();
$ This-> ajaxReturn ($ list, 'json ');
Html section
Copy codeThe Code is as follows:
<Table class = "table-striped table-bordered table-condensed">
<Tr> <th> NO. </th> <th> name </th> <th> creation time </th> <th> operation </th> </tr>
</Table>
Effect
OK