这篇文章主要为大家详细介绍了PHP利用CI的AJAX分页的简单示例,具有一定的参考价值,可以用来参考一下。
感兴趣的小伙伴,下面一起跟随四海网的小玲来看看吧!
看了一下CI的分页类没有写到关于AJAX的内容,也在论坛上看到其他几位大神写的分页类扩展,感觉其实是没有必要。代码如下:
<script>
$(.ajax_fpage).click(function(e){
var url = $(this).attr(href);
$.get(url,{},function(res){
$(#show_what_table).html(res);
});
event.preventDefault();
});
</script>
代码如下:
function ContentList($id,$p=0)
{
$this->load->library(pagination);
$config[base_url] = site_url(qyadmin/ContentList/.$id./.$p);
$config[total_rows] = $this->admin->content_list($id,$p,1);
$config[per_page] = 5;
$config[uri_segment] = 5;
$config[first_link] = FALSE;
$config[last_link] = FALSE;
$config[full_tag_open] = <p>;
$config[full_tag_close] = </p>;
$config[display_pages] = FALSE;
$this->load->helper(url);
$skin_url = base_url().APPPATH . "views/templates";
$config[next_link] = <img src=".$skin_url./images/page_next.gif">;
$config[next_tag_open] = <li class="fr">;
$config[next_tag_close] = </li>;
$config[prev_link] = <img src=".$skin_url./images/page_prev.gif">;
$config[prev_tag_open] = <li class="fr">;
$config[prev_tag_close] = </li>;
$config[anchor_class] = class="ajax_fpage";
$this->pagination->initialize($config);
$content = $this->admin->content_list($id,$p,0,$config[per_page],$this->uri->segment(5));
$fpage = $this->pagination->create_links();
$this->smarty->assign(fpage,$fpage);
$this->smarty->assign(content,$content);
$this->smarty->view(show.tpl);
}
本文来自:http://www.q1010.com/173/15121-0.html
注:关于PHP利用CI的AJAX分页的简单示例的内容就先介绍到这里,更多相关文章的可以留意四海网的其他信息。
关键词:
四海网收集整理一些常用的php代码,JS代码,数据库mysql等技术文章。