【发布时间】:2012-06-26 13:01:37
【问题描述】:
我已经为我的城市标签创建了 ajax 代码来显示来自 ajax 的各个城市数据。
我使用了以下代码:
function showBrandData(str)
document.getElementById("dvloader").style.display = 'block';
jQuery('#txtDisplayBrands').slideDown("slow");
if (str=="")
{
document.getElementById("txtDisplayBrands").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("dvloader").style.display = 'none';
document.getElementById("txtDisplayBrands").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","http://localhost/demostore/getBrandData.php?q="+str+"&page=1",true);
xmlhttp.send();
}
以下是我加载 ajax 内容的 div
<!-- div to display brands products -->
<div id="txtDisplayBrands"></div>
现在我使用以下 jquery 插件对我的项目进行分页 http://cssglobe.com/post/9801/easy-paginate-jquery-plugin-for-pagination
但是当我在我的 ajax 响应中使用它时,分页不起作用。
你能帮我解决我做错的地方吗?
感谢和问候
【问题讨论】:
-
在您的代码中使用 [$.ajax]()api.jquery.com/jQuery.ajax 其 jquery 版本的 xmlhttp 请求,如果您仍有问题,请在之后更新问题 :)
-
您可能会发现编写 10 行代码来对自己进行 ajax 分页比依赖其他人的代码更容易。这也可能使我们更容易为您提供帮助。