Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php CodeIgniter/jQuery-分页-无限分页_Php_Jquery_Codeigniter - Fatal编程技术网

Php CodeIgniter/jQuery-分页-无限分页

Php CodeIgniter/jQuery-分页-无限分页,php,jquery,codeigniter,Php,Jquery,Codeigniter,我试图在我的codeigniter项目中实现在这里()找到的无休止的分页jquery插件 我输入的jquery代码与演示页面上的代码相同 $('#results').pageless({ totalPages: 10 , url: '/theurl/index' , loaderMsg: 'Loading more results' }); 我的codeigniter控制器中的代码如下 $config['base_url'] = base_url() . 'theurl/index';

我试图在我的codeigniter项目中实现在这里()找到的无休止的分页jquery插件

我输入的jquery代码与演示页面上的代码相同

$('#results').pageless({ totalPages: 10
, url: '/theurl/index'
, loaderMsg: 'Loading more results'
});
我的codeigniter控制器中的代码如下

    $config['base_url'] = base_url() . 'theurl/index';
    $config['total_rows'] = $this->model->record_count();
    $config['per_page'] = 20;
    $config['uri_segment'] = 3;

    // Init the config
    $this->pagination->initialize( $config );

    // Create pagination
    $page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
    $data['results'] = $this->onyafeet->fetch_results($config['per_page'], $page);
    $data['links'] = $this->pagination->create_links();

    // Load the view and pass through all the data
    $this->load->view('theurl/index', $data);
当我运行代码并到达页面底部时,它确实可以工作,但它也会将enter页面加载到它为结果创建的新div中

任何帮助都将不胜感激


干杯

也许您应该将结果加载到部分视图中,否则您将再次加载整个页面。创建部分视图以加载所有数据,然后将部分视图加载到主页面:

$config['base_url'] = base_url() . 'theurl/index';
$config['total_rows'] = $this->model->record_count();
$config['per_page'] = 20;
$config['uri_segment'] = 3;

// Init the config
$this->pagination->initialize( $config );

// Create pagination
$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
$data['results'] = $this->onyafeet->fetch_results($config['per_page'], $page);
$data['links'] = $this->pagination->create_links();
// AJAX load: 
if ($this->input->is_ajax_request) {
    $this->load->view('theurl/partial/ajax_partial',$data);
}
else {
    // Load the view and pass through all the data
    $this->load->view('theurl/index', $data);
}

我认为使用这种方法应该是可行的,局部视图必须只包含您想要显示的正确部分,即包含您想要异步加载的所有内容的div。

您的意思是“整个”页面,对吗?那么,在您的视图中加载的究竟是什么,如果是“整个”页面,那么在成功分页调用时,您将嵌套该页面。嘿,David,谢谢您的回复。。。这完全有道理。。。解决这个问题的最佳方法是什么?创建一个只包含需要显示在分页结果中的数据的视图,并调用它。因此我会将其加载到配置的base_url。。。我很困惑哈哈哈。。有可能出现一些示例代码吗?下面的Chococroc的回答几乎总结了我上面的评论…:)谢谢你。。它可以工作,除了现在它加载了完全相同的结果,它也不能工作,除非我在局部视图和非局部视图上循环结果:SMmm。。。查看“pageless”的设置,我认为您的问题可能与视图的标记有关:主视图(“URL/索引”)应该有一个标记元素,您将在其中收取下一项费用。在“pageless”中,我看到您可以指定此标记元素,并可能设置:$(“#结果”).pageless({totalPages:10,url:'/theurl/index',loaderMsg:'加载更多结果',容器:'#元素'});在主页中添加BLABLA可能会奏效。