Jquery – AJAX https POST requests using jquery fail in Firefox

ajaxfirefoxfirefox-3jquery

I have a simple list of records in an HTML table with a delete link for each row. The delete link shoots off an AJAX post request to a fixed url that looks like: "/delete/record/5"

The AJAX request is created using jquery's .ajax() call with a POST message when running on a server that uses https. This call fails in Firefox 3 on OSX/Windows architectures. It works on all other browsers I've tested (OSX/Windows: Chrome, Safari, IE7.)

The requests are coming from an https site and going to the same https site. But I think somewhere during the process the original request starts off as http and there is a redirect attempt on our server to send it from http->https and Firefox rejects that redirect as some type of forgery.

Has anyone had experience doing .ajax() JQuery calls on an https site with Firefox? I notice something odd where if the request has "?var=xxx" arguments in the URL, the request seems to work more often then if it does not have those variables.

Best Solution

Sounds like you're getting an HTTP 411 error.. This error can happen if you're sending a POST request without any data.

To fix this, add an empty object ({}) to the data property to your requests:

$.ajax({ 
    url: url, 
    type: 'POST', 
    data: {}, // <- set empty data 
    success: function(data, textStatus) { 
        // do something 
    } 
});