We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

how to get a part of the Volt template (and data) from AJAX?

Hello everyone! Recently began writing project on this framework, and met one small problem: I want to learn how you can get the data from the model processed by the Volt.

For example javascript:

$.ajax({ type: 'POST', data: {visible: mode, user_id: user}, success: function(data){

For example, in the fatfree framework, you can just call like this:

echo Template::instance()->render('system/result.html');



3.6k
Accepted
answer
edited Dec '14

If what you mean is get the html result from the view engine inside your controller, try this:

//Render all the view hierarchy related to the view system/result.html
$this->view->render("<controller>", "<action>");

//Finish the output buffering
$this->view->finish();

echo $this->view->getContent();

Hope that help...



1.4k