search
Homephp教程PHP开发Yii2 framework study notes (9) -- pjax

Pjax is a relatively new thing, which refers to pushState + ajax. It takes advantage of the new features of html5 to implement some of the refresh features of ajax. Moreover, because the url has changed, the browser's forward and backward functions can also be used normally. This The difference from ordinary ajax.

Yii2 has provided complete pjax support, which is relatively simple to implement. Just use Pjax::begin/Pjax::end to frame the areas that need to be refreshed in the view. The code in the controller does not need to be done separately. Special processing, the code is as follows

Yii2 framework study notes (9) -- pjax

#If the form is included in pjax and needs to be submitted, the pjax-data parameter needs to be added. The value does not matter.

In addition, you need to submit the pjax of the form. After submitting the form, you need to pay attention to two issues:

1. If the action of the form is inconsistent with the original address, it will cause the automatically generated pager to point to It is the action to submit the form. The pager must be redirected to the original address by adding the specified route to the dataProvider in the controller when it is generated

Yii2 framework study notes (9) -- pjax

2. If the original The url has parameters. When the form is submitted, the parameters will be lost. There are two ways to deal with it. One is to put the original parameters into the hidden field of the form. The other is to add the required parameters to the url in the controller, as follows

Yii2 framework study notes (9) -- pjax

The above is the content of Yii2 framework study notes (9) - pjax. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools