gpt4 book ai didi

jquery - 在ajax请求中返回zend paginator对象,获取错误的url

转载 作者:行者123 更新时间:2023-12-01 01:52:30 25 4
gpt4 key购买 nike

我正在使用Zend Paginator在这里,在 ajax 请求中,我根据搜索结果检索对象并渲染 HTML,并将其与渲染的 Zend Paginator View 一起传递。

问题是返回的分页器没有考虑新的 url。例如,如果我不使用 ajax 来执行此操作,我将读取我的页面 url:

www.mysite.com/?search=something&page=2

但是,从 ajax 查询中,它不起作用,搜索变量不会附加到分页器链接中的 url 中。请帮忙。

最佳答案

我假设您网站上的某个位置有分页链接,这些链接指向您的pagination.phtml 文件中生成的不同页面。

OnClick 您需要获取 href 属性 并加载如下内容:

function getContents() {
var url = window.location.protocol + "//" +
window.location.host + $(this).attr('href');

var jqxhr = $.post(url, {
"format" : "json"
}, function(data) {
displayContents(data);
}, 'html');
return false;
}

$(document).ready(function() {
$("#paginator a").each(function() {
$(this).click(getContents);
});
});

这样你就可以得到你的经典网址

www.mysite.com/?search=something&page=2

也许您需要更改 url 字段。只需提醒 url 字段并查看需要更改的内容即可。

这是有关该内容的教程(无需搜索):Zend Framework 1.9 tutorial 14: ajax requests part 1

关于jquery - 在ajax请求中返回zend paginator对象,获取错误的url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5633045/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com