How to use Thinkphp+Ajax to realize the function of searching list with keywords without refreshing paging
This article mainly explains "how to use Thinkphp+Ajax to achieve the search list with keywords without refresh paging function", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "how to use Thinkphp+Ajax to achieve search list with keywords without refresh paging function" bar!
Thinkphp+Ajax search list with keywords no refresh paging instance, two query conditions, paging and search keywords, friends who understand can also add other paging parameters.
Search for # keyword and load content area # ajax_lists
Var url_ajax = "_ _ APP__/Box/orders"; $(function () {$("# ajax_lists"). Delegate (".pager a", "click", function () {var page = $(this) .attr ("data-page"); / / get the current click paging getPage (page);}) getPage (1) / / initialize paging}) function getPage (page) {$("# ajax_lists") .html ("list"); var keyword = $("# keyword") .val (); $.get (url_ajax, {keyword: keyword, p: page}, function (data) {$('# ajax_lists') .html (data);})})}
Remote ajax load list data
Public function orders () {$sql = "1cm 1"; $keyword = trim (I ('get.keyword')); if (! empty ($keyword)) {$sql. = "AND name like'%". $keyword. "%'";} $count = M ('js')-> where ($sql)-> count (); / / calculate the total $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 () } Thank you for your reading, the above is the content of "how to use Thinkphp+Ajax to achieve the function of search list with keywords without refresh paging". After the study of this article, I believe you have a deeper understanding of how to use Thinkphp+Ajax to achieve the function of search list with keywords without refresh paging, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!