Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

dianaMa's avatar

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'));
    
}
0 likes
8 replies
bobbybouwmann's avatar

What is the exact error you get? What is the error your developers console shows?

dianaMa's avatar

Hi, if I try to sort or search, the console (Chrome) show: GET .../fetch_data?sortby=name&sorttype=desc&query= 500

(... is the URL)

dianaMa's avatar

fetch_data is the route, sortby & sorttype comes from an input-field, query has only value, if a search-String is entered

Error 500

Snapey's avatar

Make sure you change your passwords. You have just exposed all your debug information, including your database credentials.

Snapey's avatar

I think the problem is that your .htaccess file in your public folder is not passing any of the query string parameters to Laravel

dianaMa's avatar

@SNAPEY - oh shit, thank you, stupid me ... I was in a hurry. Changed all ...

dianaMa's avatar

@SNAPEY - ... hm ... and what do I have to do ? My htaccess looks like this:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /index.php?/ [L]
dianaMa's avatar

ok, solved. Changed the rights via ftp and it worked ...

Please or to participate in this conversation.