Home > Article > Backend Development > Using Pjax in Yii2 causes the Yii2 inline script to fail to load, yii2pjax_PHP tutorial
When I use An error occurred when loading <strong>ActiveForm</strong>
of Yii2, normally it is
The two js of
<strong>ActiveForm</strong>
should be loaded first, but the actual situation is
typeError:JQuery(...).yiiActiveForm is not a function.
This issue has been discussed and resolved in the issues on github.
Pjax first executes the inline <script> through html()</span></span>, and then executes the tag through executeScriptTags() <script> with src, so </script>yiiActiveForm cannot be found. The Pjax author refuses to use JQuery.getScript() to solve this problem because the use of eval in the function does not comply with CSP (Content Security Policy) for security reasons
A participant of Yii2 modified Pjax so that Pjax can work well in Yii2
Personal test showed no problem.
Ah
’s