我有3个文件的index.php,.js文件和a.php文件。我通过js(jquery)文件向a.php发送了ajax请求。我是在HTML响应,(在1 HTML响应)有3个div,但我想一次显示一个div。然后点击下一个div,这是在相同的HTML响应。它基本上是通过服务器端数据进行客户端分页(从1个AJAX获得)。但我无法在索引页面中逐一处理3个div。客户端分页通过服务器端数据(Ajax)
1. 的请求进入 -
<script>
$(document).ready(function(){
showitem(id);
});
</script>
简单的查询被处理。
功能showitem(ID){
$.ajax({ type : "POST", cache : true, //dataType: "json", url : "a.php", data : { proid:id }, success: function(data) { $("#match_item_display").html(data);// This is span in index.php } });
}
3. 在响应(比方说)1得到的HTML的div形式9层的元件(3在这种情况下),我想一次显示3个。
$start=0; $end=6;
for($d=0;$d<$len;$d++)
{
if($end>$count)
{
$end = $count;
match_pro("Closley Match", array_slice($recent_arr, $start, $end),$d);
}
else
{
match_pro("Closley Match", array_slice($recent_arr, $start, $end),$d);
//break;
}
$start=$end; $end=$end+6;
}
它的回报3个格作一个...输入反应
- 要显示 - 下一个和上一个按钮。
SUMMARY - > 1-ajax请求,一些HTML div作为响应,按顺序显示它们在一个按钮上单击一次。
我正在做客户端分页,因为查询一次不能返回超过9-12个响应。所以客户端脚本应该是最佳的。
我们需要看到的代码是在a.php中 - 但是@rajesh是我认为正确的。返回你想要在你的JSON响应中显示的所有项目,并使用jQuery将它们注入到DOM中。 – halfer 2012-02-15 14:19:52