如何在cakephp 2中使用ajax分页更新url


早上好

我使用cakephp2.3通过ajax创建了一个分页,它工作正常。问题是url中的页码没有更新。

他是这样的:

  / Localhost/cakephp-2.3.4/Anuncios/inicio /

并希望出现在页/类型,或多或少,如果我点击第7页,url必须是:

  / Localhost/cakephp-2.3.4/Anuncios/inicio/page: 7

有人知道我该怎么做吗?

使用history.pushState

为排序和分页设置JS链接,例如:

if (history && history.pushState) {
        $('.yourTable th a, .paginationBar .controles a').on('click', function () {
            $.getScript(this.href);
            history.pushState(null, document.title, this.href);
            return false;
        })
        $(window).bind("popstate", function () {
            $.getScript(location.href);
        });
    } // history

最新更新