Search #keyword and load content area #ajax_lists
<input id= "keyword" class= "input" type= "text" value= "" placeholder= "please input search keyword"/>
<input class= "btn" type= "button" value= "Search"/>
var url_ajax = "__app__/box/orders";
$ (function () {
$ ("#ajax_lists"). Delegate (". Pager a", "click", Function () {
var page = $ (this). attr ("Data-page");/get Current Click Paging
GetPage (page);
})
GetPage (1); Initializing pagination
})
function GetPage (page) {
$ ("#ajax_lists"). HTML ("
Loading
"); var keyword = $ ("#keyword"). Val (); $.get (Url_ajax, {keyword:keyword, p:page}, function (data) {$ (' #ajax_lists '). HTML (Data)})}
Remote AJAX Load Order list
Public Function orders () {
$sql = "1=1";
$keyword = Trim (I (' Get.keyword '));
if (!empty ($keyword)) {
$sql. = "and name like"% " . $keyword. "%'";
}
$count = M (' js ')->where ($sql)->count (); //Total count
$Page = new \think\pageajax ($count, 10);
//
$lists = M (' js ')-> where ($sql)->limit ($Page->firstrow. ',' . $Page->listrows)->order (' id DESC ')->select ();
$this->assign ("page", $Page->show ());
$this->assign ("lists", $lists);
$this->assign ("keyword", $keyword);
$this->display ();
}
Figure: