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.
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:
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);
});
});
This way you get your classic url
www.mysite.com/?search=something&page=2
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