Answer the question
In order to leave comments, you need to log in
AJAX response with HTML code in Yii2?
Lord.
In yii2 - newbie and first problem.
I implement a simple ajax search - on the keyup event, a request is made to the controller-> BD and then in the controller in a loop, I write data to HTML tags that I store in one variable, like $response.=''
Then I return this variable and insert it into the desired block on site.
Everything works, except for the Modal::begin(); widget;
I can't write the modal code to a variable and that's the problem. Not all HTML is displayed, but only the button of the modal window.
I understand that this is the most crooked implementation, but there is really little experience in this framework.
Answer the question
In order to leave comments, you need to log in
Specifically in your case
ob_start();
Modal::begin();
echo 'contnetn';
Modal::end();
ob_start();
$out .= ob_get_clean();
In your Action that processes ajax, return the desired view
, just don't forget to create this view, and in ajax in response, catch this html and paste it where you need
it, if very briefly)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question