bradley546994 bradley546994 - 11 months ago 154
jQuery Question

Laravel refresh data after ajax

He is currently working on code that has to filter the data in the table. Ajax will call the link and gets the response (json) results with answer. However, I came across a problem. I have to somehow render tables and I do not want to do this by append etc.

Can I somehow again generate views or blade file?

The default view is DefController@index but ajax use url which controller is DefController@gettabledata.

public function gettabledata($id){

return response()->json(Def::find($id)->getallmy->all());



You can put the part in your template corresponding to the table in a separate .blade.php file, and @include that in your main layout.

main.blade.php :

  <div class="table-container">



  @foreach($rows as $row)
      <td> $row->title ... </td>

In this way you can use a simple jQuery $('div.table-container').load(url) and on your server just render and respond that part as an html string. return view('table', $data)


function refreshTable() {
  $('div.table-container').load(url, function() {