Laravel Ajax "Get" Method - Error 500
Hello, I have maded 2 laravel project, one for testing ajax that working fine, and other one that have same ajax give error 500.
here is my controller
class SearchOrdersController extends Controller
{
function fetch_data(Request $request)
{
if ($request->ajax()) {
$sort_by = $request->get('sortby');
$sort_type = $request->get('sorttype');
$query = $request->get('query');
$query = str_replace(" ", "%", $query);
$orders = Order::query();
if (is_numeric($query)) {
$orders->where('amount', '<', $query);
} elseif (!empty($query)) {
$currency = Currency::where('name', 'like', '%' . $query . '%')->first();
if (!is_null($currency)) {
$orders->where('currency_id', $currency->id);
}
}
$data = $orders->orderBy($sort_by, $sort_type)->paginate(6);
return view('panel.user.order.pagination_data')->with(['data' => $data])->render();
}
}
}
my javascript :
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$(document).ready(function() {
function fetch_data(page, sort_type, sort_by, query) {
$.ajax({
url: "/pagination/fetch_data?page=" page "&sortby=" sort_by "&sorttype="
sort_type "&query=" query,
success: function(data) {
$('tbody').html('');
$('tbody').html(data);
}
})
}
}
and my route without any middleware :
Route::get('/pagination/fetch_data', 'User\SearchOrdersController@fetch_data');
the csrftoken for "Get" not needed! why this code is working in another laravel project and not in this?
thanks regards
CodePudding user response:
Solved, these errors is on Laravel.log
storage/laravel/laravel.log
