2

我正在尝试创建一个加载更多按钮。如果单击它必须加载附加到上一个记录的下一个记录。这是我的控制器类

class Sample  extends CI_Controller{
  function wall($start)
{
$start = $this->input->post('start');

$resultjson = $this->curl->simple_get("http://www.mywebsite.com/api/posts.php?start=$start&count=10");
$resultant_data = json_decode($resultjson,true);
$data['sample'] = $resultant_data;
$this->load->view('posts',$data);
}
}

在我看来

<html>
<head>
<I have some js files such as masonry>
<script type="text/javascript">
function loadmore()
{

$.ajax({
type:"POST",
url:"http://www.server.com/application/index.php/Sample/wall/",

data :"start=10",
//dataType : 'json',

         success: function (data) {

             alert(data);
         }
});
}
</script>

</head>
<body>
. . . . .
. . . . .
<div id="loadmore" style="margin-top:75%;">
<input type="button" value="loadmore" onclick="loadmore()">
</div>
</body>

</html>

Sample 是类名,wall 是方法名问题是如果我直接在 url 中调用www.mysite.com/application/sample/wall/10它会给我接下来的 10 条记录....但是我无法显示接下来的 10 条记录如果单击加载更多按钮,则记录。即,如果我致电www.mysite.com/application/sample/wall,我将得到 0 到 10 和一个加载更多按钮。单击按钮时,它必须显示下一个十以及较早的数据。 谁能帮帮我吗

4

1 回答 1

4

首先加载www.mysite.com/application/sample/wall/0(默认),与您的代码相同。

添加if($start == ''){$start = 0;}您的控制器。

于 2012-12-19T13:18:09.213 回答