Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

242
Views
How can I return view and pass in data in Laravel with Ajax?

I have an issue with my Ajax function which is supposed to call a Laravel view with $paginatedResults data which is returns from another function. For some reason it returns error 500. I know for a fact that $paginatedResults returns the right data as if I var_dump it's correct.

public function ajaxSearch(Request $request)
{
    $data = $request->input('searchVal');
    $pageNr = $request->input('pageNr');
    $dataType = $request->input('dataType');
    $paginatedResults = $this->paginateTypeResults($data, $pageNr, $filetype);

    $loadData = view('search.searchresults')->with($paginatedResults)->render();
    echo response()->json($loadData);
}
about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

This is json response

return response()->json([
   'html' => view('search.searchresults', ['paginatedResults' => $paginatedResults])->render()
]);

After success

$.ajax({
   //
   dataType: 'json',
   success: function(response) {
      $('.//here').html(response.html)
   }
})
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!