Pjax is not working, reloads the whole page
Home » Blog » Yii2.0 framework » Pjax is not working, reloads the whole page

Pjax is not working, reloads the whole page

Updated:   Yii2.0 framework 1 min read

Your support helps keep this blog running! Secure payments via Paypal and Stripe.


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 
]);

Your support helps keep this blog running! Secure payments via Paypal and Stripe.


Senior WordPress Developer (Freelancer)

Senior WordPress Developer (Freelancer)

I’m a professional WordPress and WooCommerce developer based in Chiang Mai, Thailand, with over a decade of experience creating fast, secure, and scalable websites. From custom themes and plugins to full WooCommerce stores, I help businesses build a strong and reliable online presence. Need a freelance WordPress developer you can count on? View my portfolio or get in touch to discuss your project.