AJAX响应为空

I've tried this like 8 hours and I don't get it.

With $.ajax I get datas from my database via PHP-script. But in this case it doesn't seem to work and I don't no why. The data2 is empty, no matter what.

$.ajax({
  url: 'http://myurl.de/get', 
  data: [{ 'person_id': 2, 'action': 'getLinks' }],
  method: 'POST',
  success: function(data2){
    console.log(data2);
  }
});

The PHP-script (important parts) looks like this

function getLinks($person_id)
{
    /* sql here */  

    /* format sql-output here */

    return $output;
}

if($_POST['action'] == 'getLinks'){
    echo getLinks($_POST['person_id']);
}

The funny thing is, I have the exact AJAX-request in the JavaScript-file some lines above with another action and it works perfectly. When I try to get the data directly in the PHP-file I get the result. The return $output is always with the data, but in don't comes to the JavaScript file.

The AJAX always calls the success-function, but with no data2.

Try using only object as data, without wrapping it in an array:

$.ajax({
  url: 'http://myurl.de/get', 
  data: { 'person_id': 2, 'action': 'getLinks' },
  method: 'POST',
  success: function(data2){
    console.log(data2);
  }
});

Try like this

   $.ajax({ url: 'http://myurl.de/get', 
                data: { 'person_id': 2, 'action': 'getLinks' },
                method: 'POST',
                success: function(data2){
                    console.log(data2);
                }
        });

I've updated data line

use this:

data: { 'person_id': 2, 'action': 'getLinks' },

Instead of

data: [{ 'person_id': 2, 'action': 'getLinks' }],

data can be an object or string or an array. When you are sending data as

data: [{ 'person_id': 2, 'action': 'getLinks' }],

it will be basically [>Object] which is an array of object. You can still send in this way if there is a proper mechanism to retrieve it in the server side. But sending { 'person_id': 2, 'action': 'getLinks' } you are sending data as object & I presume you server side is configured to accept data in this format