We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

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



33.8k
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.



-60

Buen Día que problema tenia del lado del servidor?

Use english.



-60

good morning wath problem did you have in the server?