How can I return a view from an AJAX call in Laravel 5?

The view() function just creates an instance of the View class. Not just an HTML string. For that you should call render():

$returnHTML = view('job.userjobs')->with('userjobs', $userjobs)->render();
return response()->json(array('success' => true, 'html'=>$returnHTML));

Leave a Comment