在ajax请求中返回zend paginator对象,获取错误的url
我在这里使用 Zend Paginator ,在 ajax 请求中我根据搜索结果检索对象并渲染 HTML 并将其与渲染的 Zend Paginator 视图一起传递。
问题是返回的分页器没有考虑新的 url。例如,如果我要在没有ajax的情况下执行此操作,我将读取我的页面网址:
www.mysite.com/?
search=something&page=2但是,从ajax查询中,它不会以这种方式工作,不会附加搜索变量到分页器链接中的 url。请帮忙。
I'm using Zend Paginator here, in an ajax request I am retrieving objects based upon search results and rendering the HTML and passing it along with a rendered Zend Paginator view.
The problem is that the returning paginator doesn't take into account the new url. for example if I were to do it without ajax I would have my page url read:
www.mysite.com/?search=something&page=2
However from and ajax query it doesn't work that way the search variable is not appended to the url in the paginator links. Help please.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我假设您网站上的某个位置有分页链接,它们指向pagination.phtml 文件中生成的不同页面。
OnClick 您需要获取 href 属性 并加载如下内容:
这样您就可以获得经典 url,
也许您需要更改 url 字段。只需提醒 url 字段并查看需要更改的内容即可。
这是有关该内容的教程(无需搜索): Zend Framework 1.9教程14:ajax请求第1部分
I assume you hava pagination links somewhere on your site that point to the different pages that are generated within you pagination.phtml file.
OnClick you need to get that href attribute and load the contents like that:
This way you get your classic url
maybe you need to change the url field. Just alert the url field and look what needs to be changed.
Here is a tutorial on that (without search) : Zend Framework 1.9 tutorial 14: ajax requests part 1
如果没有看到您的代码,我无法确定,但听起来您的分页器控件视图脚本(即呈现下一个、上一个等链接的
.phtml
文件)正在使用$ this->url()
但您尚未将其配置为检测搜索参数并将其附加到链接末尾。如果您的控制视图脚本特定于该分页器,请尝试在
标记的 href 参数中手动添加“?search=something”。这应该迫使它在输出中包含这些内容。
如果您能为我们提供控制器和视图中的代码,展示您如何实现分页器和呈现页面,那就太好了。或者现场演示总是好的:D
Without seeing your code I can't be sure, but it sounds like your Paginator Controls View Scripts (i.e. the
.phtml
files which render your Next, Previous, etc links) is using the$this->url()
but you haven't configured it to detect and append the search parameter onto the end of the links.If your control view scripts are specific for that Paginator, try manually adding the "?search=something" in your
<a>
tag's href parameter. This should force it to include these in the output.It would be great if you could provide us with the code from your Controller and View showing how you are implementing the Paginator and rendering the pages. Or a live Demo is always good :D