Pjax - Update Content Inside A Div

Hello Guys,

I’m trying to use Pjax for the ajax stuff in my project.

For simplicity, my goal is to update the div #aboutdiv with the content of site/about.

My code:




views\site\index.php


...


    <div id="aboutdiv"></div>


    <?php Pjax::begin() ?>


        <?= Html::a(

            'about',

            Url::to(['site/about']),

            ['data-pjax'=> '#aboutdiv']

        ) ?>


    <?php Pjax::end(); ?>

...







controllers\SiteController.php


...

public function actionAbout()

    {

        if (Yii::$app->request->isPjax) {

            return $this->renderPartial('about');

        } else {

            return $this->render('about');

        }

    }



It’s not working. My link acts like a normal link, no ajax requests, etc.

What am I doing wrong?

Thank you guys, for this amazing framework.

code looks okay, check for errors in firebug console for example.

Thanks Cebe, the problem was timeout.

I am using a code exactly like yours. The problem is that when I click the link

id doesn’t update the #aboutdiv but the result will update the

pjax section, so the link will disappears and the #aboutdiv will remains the same.

I think pjax is not to be used this way…

I´m using pure jquery/ajax now.

Take a look at this wiki, It could give you a clue.