CI分页问题
我的页面如下:http://codeigniter.org.cn/forums/data/attachment/album/201311/06/164611rcsqckhdyk1cc1sq.png
选择游戏列表,会在红框处显示相关信息。但是信息量太大了,我需要用分页来显示。
view层的ajax方法如下:
$.ajax({ url: '<?php echo base_url();?>c_error/get_error',//控制层的类名
type: 'POST',
data:{'id':t_id},//参数
dataType: 'json',
timeout: 3000,
async:false,
success:function(data){
if(data.error==0)
{
t_obj = document.getElementById('info');//红框ID
t_obj.innerHTML="";
for(i=0;i<data.data.count;i++){
t_obj.innerHTML +=data.data;//显示在红框里的列表
}
}else{
alert("无错误信息");
}
},
error:function(data){
alert("选择出错了");
}
});
控制层的get_error方法如下:
public function get_error() { $t_id = $this->input->post ( 'id' );
$t_table_name = "game" . $t_id;
$return_info ['data'] = $this->m_error->get_error ( $t_table_name, $t_id );
if($return_info ['data']['count']<=0)
{
$return_info ['error'] = 1;
}else{
$return_info ['error'] = 0;
}
$jsonencode = json_encode ( $return_info );
//$this->cat_log_model->catLog($jsonencode,0);
echo $jsonencode;
}
模型层的get_error方法如下:
function get_error($a_table_name, $a_id) {
$t_where = array ('table_name' => '0000' . $a_id );
$t_data = $this->mongo_model->findone ( $a_table_name, $t_where );
$t_ret = array ();
$t_day = array ();
$t_index = 0;
foreach ($t_data ['error'] as $key => $value ) {
$t_ret [$t_index] = "<div ><font color=#FF0000>" ." " . date("Y-m-d H:i:s",$value ['time']/1000) . " </font>" . "<font color=#8600FF>" . $value ['player_id'] . "发来错误信息:" . "</font>" . "<font color=#4D0000>" . $value ['error'] . "</font></div>";
$t_day [$value ['player_id']] = 1;
$t_index ++;
}
$t_ret ['count'] = $t_index;
$t_ret ['day_count'] = count ( $t_day );
$t_index = 0;
foreach ( $t_day as $key => $value ) {
$t_ret ['player_id'] [$t_index] = $key;
$t_index ++;
}
return $t_ret;
}
以上代码可以把所有匹配的数据都读取出来,返回到控制层,再在view层的红框里显示出相应数据。
可是这个数据量太大了,我想在选择游戏后,在红框部分,以分页的形式显示出数据列表,该怎么做呢?
各位大侠帮帮忙吧!!! 忘记说了,我用的是mongodb,在模型层里读的就是一个大数组。 这涉及的面太多了吧。
分页要写蛮多东西吧 js ci 莫名奇妙 发表于 2013-11-6 21:17 static/image/common/back.gif
这涉及的面太多了吧。
分页要写蛮多东西吧 js ci
具体要在哪写呢?怎么写?
小花鱼 发表于 2013-11-7 09:06 static/image/common/back.gif
具体要在哪写呢?怎么写?
搜索下 “codeigniter ajax分页” 或者“codeigniter ajax pagination”
大侠们!大仙们!有没有人帮帮我啊!~~~~~~~~~~~~~~~~ CI的分页类本质上讲只是帮你实现了前端的html,后端的业务逻辑都是需要自己写的。 分页都让你写成这样了~~不用那么麻烦 具体是什么问题呢?
问问题最好具体点,类似XX如何写这种一般都不太好回答。建议尽量问一些具体的问题。 Hex 发表于 2013-12-5 13:06 static/image/common/back.gif
具体是什么问题呢?
问问题最好具体点,类似XX如何写这种一般都不太好回答。建议尽量问一些具体的问题。 ...
具体的问题就是,我有一万条数据,不想一下都取出来放在ajax返回的data里,想通过分页一百条一百条的取,每点一次下一页或页码,就能取mongodb里相应的值。
我现在不知道该在哪里写。也不知道如何写。
页:
[1]
2