I am new to Laravel and I am trying to do this:

I have a webpage that list hundreds of apartments, I already did it with pagination in laravel, the thing is I have a filter in the same page in left column, and I want to load again the data according to the filter applied by the user using ajax in the conta.

I realized the response is just sending the data filtered but with no design nor html and I need to list again the information with the same design it was displayed before the filter

return Response::json( $response );

Is there any option to send the response to a view first or a place where I can listed and then return it to the container with style and html.?

I don't know if I was clear please excuse my english.


Foi útil?


Yeah, you can do something like this:

$view = View::make('partial_template')->with('apartments',$apartments)->render();

return array('html' => $view, 'status' => 'OK');

It uses a partial template to render the results.

Outras dicas

For laravel5

It has been changed in laravel5. If any one looking solution for laravel5 then he should use the following snippet:

$view = view('partial_template')->with('apartments',$apartments)->render();
return Response::json(array('html' => $view, 'status' => 'OK'));
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow