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.