1

我为我的城市选项卡创建了 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 响应中使用它时,分页不起作用。

你能帮我看看我做错了什么吗?

感谢和问候

4

1 回答 1

0

该站点的默认代码:

<script type="text/javascript">

  jQuery(function($){ 
  $('ul#items').easyPaginate();
  }); 

</script>

在页面加载时调用。之后您的 ajax 调用将被执行,因此您需要在 ajax 调用中加载的元素上调用分页代码。

考虑在 if 语句中添加它 if (xmlhttp.readyState==4 && xmlhttp.status==200)

于 2012-06-26T13:11:12.940 回答