且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从Laravel 5中的AJAX调用返回视图?

更新时间:2021-10-12 22:58:26

view()函数只创建 View 类的实例。不只是一个HTML字符串。为此你应该调用 render()

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));