M
M
Maybe_V2016-06-20 00:49:59
JavaScript
Maybe_V, 2016-06-20 00:49:59

How to ignore yii markup on ajax request?

I make an ajax request that refers to the controller's action.

As a result, an html page should be accepted in response, which is redrawn before the creation of the content!

All implemented:

ajax request:

$.ajax({
                            url: "http://portfolio/blog/index",
                            data: 'id='+result.id,
                            dataType: 'html',
                            success: function (data) {
                               $('.conteiner').html(data);
                            },
                            error: function () {
                                alert("error");
                            }
                        });


controller:

public function actionIndex()
    {
        
            return $this->render('block-blog', [
                'posts' => Post::find(),
                'category' => Category::find(),
                'currentCategory' => Yii::$app->request->get('id'),
            ]);
      

    }



But there is one caveat - not the actual code that is in block-blog.php is returned, but the html markup of the footer, tabs, etc. yii.

That is, it looks like this:
a87cb8abe83d46b99f8cf545f3ab426f.png


How can I make it so that the actual markup is accepted, without yii tags?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
polar-bear, 2016-06-20
@prokopov-vi

return $this->renderAjax('block-blog', [

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question