» » » Pjax is not working, reloads the whole page

Pjax is not working, reloads the whole page

posted in: Yii2.0 framework

Yii version 2.0.13.1

Recently I am working on building the custom application with Yii2.0. I have one issue with Pjax widget. It turns out to be a common issue when you are working on Pjax.

Problem
I want to render the creating form in the modal on an index page. After users submit the form, the modal will be closed and the grid view will be refreshed. This way, users won’t leave the index page. The problem is Pjax reloads the whole page instead of reloads only Pjax container after submitting the form.

Cause
The cause of the issue is Pjax timeout. If the server does not respond within the timeout, a full-page load will be triggered. The default timeout is 650.

Solution
Increasing the timeout

Example

Pjax::begin([ 
    'id' => 'pjax-container',
    'timeout' => 5000 
]);