Not sure if it's a real issue or not, or if it should be dealt with by Pjax js.
When using Pjax with Pagination it will append the _pjax query string parameter to the paging a elements.
The Pjax js then also appends the query string again so the request made is ?page=2&_pjax=#w0&_pjax=#w0
@Alex-Code Could you share some code. i can't confirm this on my end.
I've used something as simple as this:
Pjax::begin();
echo GridView::widget(['dataProvider' => $provider]);
Pjax::end();
and i got:
http://dev.com/yii2/apps/basic/web/index.php?r=site/about&page=6&_pjax=%23w0
This will only occur on the second request.
The first request will send the _pjax parameter which then gets put in the paging query string by Yii.
So the href on the paging links are like ?page=1&_pjax=#w0
When a paging link is then clicked again PJax will then also append the _pjax parameter again.
It can be fixed by putting this in the init() of PJax.
\yii\helpers\ArrayHelper::remove($_GET, '_pjax');
I confirm it. "_pjax" appends to sorting links too.
@qiangxue confirmed... Nevertheless, this is not really a bug as pjax issue is just appending twice the same parameter. The issue seems not to affect its functionality.
The only way to tackle this issue is by working on the library pjaxit self.
The only way to tackle this issue is by working on the library
pjaxit self.
Well, not sure this is a pjax issue. As far as I understand the pjax library, pjax add this parameter for caching issues :
// We want the browser to maintain two separate internal caches: one
// for pjax'd partial page loads and one for normal page loads.
// Without adding this secret parameter, some browsers will often
// confuse the two.
if (!options.data) options.data = {}
options.data._pjax = context.selector
But, when creating links (for pager or sorters), Yii will add all current GET parameters (to keep track of current filters), and therefore, will add this _pjax to all links.
We can easily fix that by removing the _pjax parameter when rendering view inside the pjax container.
EDIT: Sorry, didn't see that the solution was already proposed by @Alex-Code
I've checked again on how we can fix it in jquery-pjax.js.
In fact, it can be easily solved by stripping the _pjax parameter from the URL just before calling $.ajax().
I'll make a new PR on the new yiisoft/jquery-pjax external package.
I think this issue can be closed now.
I have error with _Pjax but I not think how solution, and I read this is issues and I think isnt good change vendor.
In my gridview I have one Url so after on click the url change for end "&_Pjax=..."
and I have error:
Uncaught TypeError: Cannot read property '0' of null
at extractContainer (:733:69)
at jQuery.fn.init.options.success (:301:21)
at fire (jquery.js:3291)
at Object.fireWith [as resolveWith] (jquery.js:3421)
at done (jquery.js:9533)
at XMLHttpRequest.(jquery.js:9785)"
Most helpful comment
This will only occur on the second request.
The first request will send the
_pjaxparameter which then gets put in the paging query string by Yii.So the
hrefon the paging links are like?page=1&_pjax=#w0When a paging link is then clicked again PJax will then also append the
_pjaxparameter again.It can be fixed by putting this in the
init()of PJax.\yii\helpers\ArrayHelper::remove($_GET, '_pjax');