I am using cakephp ajax pagination for my web application.
In this application i have implemented search filters also. When user filter the records, i submit the search form using GET method, in controller i get the filter variables and append them to the paginator helper like this.
$this->paginator->options(array(
'url' => array_merge($this->passedArgs, array('?'=> $query_string)),
'update' => '#tlist',
'evalScripts' => true)
);
My problem is that in my pagination link my all & is get converted into & See below and look at the bold part.
<a href="/sites/tutor/users/ajaxtutor/page:2?gender%5B0%5D=1
&gender%5B1%5D=2" id="link-1795722171" />;
And when i click on the link i do get query String as below:
[gender] => Array
(
[0] => 1
)
[amp;gender] => Array
(
[1] => 2
)
how to remove this extra amp;
from the query string.
Can anybody help how to cope with this situation.
As guffa said the conversion is correct from &
to &
as it is html standard.
The problem was that cakephp picks pagination link's href part which contains &
in place of &
and put it into ajax url section. See below for example:
<a href='somedomain.com?&a=1&b=2>1</a>
$("#link-1478709635").bind("click", function (event) {
$.ajax({
url: "somedomain.com?&a=1&b=2"
});
return false;
And when we click on the link it will take &
in place of &
with it.
As a solution i used Post method in place of GET method to post my data back with pagination links in paginator options like this:
'data'=>http_build_query($this->request->data),