Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

500 error with AJAX POST

Hello,

Has anyone had any experience with 500 errors from a server when using AJAX?

Here is my JavaScript:

var specify = function(names){
    $.ajax({
        url: 'controller/action',
        type: 'POST',
        async: false,
        cache: false,
        data: {name:names},
        success: function(response){
            jsondata = JSON.parse(response);        
        }
    });
    return jsondata;
}

When this function is called, the server responds with:

POST https://example.net/controller/action 500 (Internal Server Error) or Failed to load resource: the server responded with a status of 500 (Internal Server Error).

Does anyone have any ideas why this might be?

This works just fine when I'm using XAMPP on windows without an ssl. When I move it over to my Linux server, it fails everytime. Maybe it has something to do with the ssl certificate on my Linux server?

Thanks



16.9k
Accepted
answer

Can be of the URL, the data (you don't pick well names), or something in the server.

Also, you don't need to do JSON here; access the data response with response["whereDataLies"], setting it previously in the server ($response->setJsonContent(array("whereDataLies" => data)). Try putting an string where data to do testing.

Thanks for the comment!

I found the problem (server-side) as you might have imagined.