What is the exact error you get? What is the error your developers console shows?
May 6, 2019
8
Level 1
Ajax GET error on shared hosting
Hi everyone,
I know this is discussed very often but no solution worked for me ...
I have data in a view (output as table) that i can sort and search. Locally it works as it should, but on my shared hosting (1&1) it causes an error:
Console: jquery-3.3.1.min.js:2 GET .../fetch_data?sortby=name&sorttype=desc&query= 500 jquery-3.3.1.min.js:2 XHR failed loading: GET ".../fetch_data?sortby=name&sorttype=desc&query=".
can anybody please help me?
JS:
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
function fetch_data(sort_type, sort_by, query) {
$.ajax({
type: 'GET',
url: 'fetch_data?sortby=' + sort_by + "&sorttype=" + sort_type + "&query=" + query,
dataType: 'json',
success: function (data) {
$('tbody').html('');
$('tbody').html(data);
},
error: function(thrownError) {
console.log(thrownError );
}
})
}
controller:
function fetch_data(Request $request)
{
$sort_by = $request->get('sortby');
$query = $request->get('query');
$sort_type = $request->get('sorttype');
$query = str_replace(" ", "%", $query);
$data = Member::where('name', 'like', '%'.$query.'%')
->orWhere('vorname', 'like', '%'.$query.'%')
->orWhere('status', 'like', '%'.$query.'%')
->orderBy($sort_by, $sort_type)
->get();
return view('anzeigen_daten', compact('data'));
}
Please or to participate in this conversation.