You could return a HTML view JSON encoded and insert back into the DOM such as
$html = View('admin.comments._comments', $view_data );
return \Response::json(['status' => 'true','html' => $html->render() ]);
(an example from an admin panel in one of my projects)
else just replace the view with an array of data and insert back into the DOM accordingly.
Hope it helps.
jacksoncharles said:
You could return a HTML view JSON encoded and insert back into the DOM such as
$html = View('admin.comments._comments', $view_data ); return \Response::json(['status' => 'true','html' => $html->render() ]); (an example from an admin panel in one of my projects)
else just replace the view with an array of data and insert back into the DOM accordingly.
Hope it helps.
thanks, this works, but i'm not sure of the jQuery part how to I access it in my view?
According to your code it will exist in "html"
success: function(html) {
console.log(html);
return $data // ??????
},
So from there you need to insert the HTML into your webpage replacing or appending to whatever DOM element you want.
success: function(html) {
if( html['status'] == 'true' )
{
$('#some_element').replace(html['html']);
}
else
{
// Status not equal true, do something else
}
},
PS> Replace
success: function(html) {
with something like
success: function(responseData) {
More conventional and you are not always returning HTML
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community