Categories
Laravel

Laravel 5 render a view and store it’s contents in a variable

Sometimes you may want send the rendered view in the ajax response instead of showing on the browser.

To return html in the ajax response first you need to store the blade engine compiled HTML into the variable in side your controller action then you need to return the variable, you can store the compiled output into variable by type casting or by using render() method on the view object to return the content in string format.

Here is the trick:

By Arjun

I am Arjun from Hyderabad (India). I have been working as a software engineer from the last 7+ years, and it is my passion to learn new things and implement them as a practice. Aside from work, I like gardening and spending time with pets.

2 replies on “Laravel 5 render a view and store it’s contents in a variable”

Leave a Reply

Your email address will not be published. Required fields are marked *