Firefox 3.0: 411 Length required with JQuery

I am currently working on a small project for my own. My favourite (and the only one tester) was complaining on some of “ajax” features. Tests were done with use of Firefox 3.0 - I was developing on Firefox 3.5 and had absolutely no problems with those problematic features. Anyway I decided to check this out an downloaded 3.0 version ( most recent is 3.0.11). You can have multiple instances of Firefox on Your machine - just make sure You install them in separate directories. Then the best would be to create different user profiles - like one default and one for testing. You can manage profiles using :

firefox.exe -ProfileManager

And then You can run prev version by:

\path\Firefox 3.0\firefox.exe -P test_profile -no-remote

Having this set up You can test in Firefox 3.0. I was able to reproduce error and check what is going on in firebug. I was receiving HTTP 411 error, which says:

Your Web server thinks that the HTTP data stream sent by the client (e.g. your Web browser or our CheckUpDown robot) should include a ‘Content-Length’ specification. This is typically used only for HTTP methods that result in the placement of data on the Web server, not the retrieval of data from it.

It looks like jQuery (1.3.2) ajax calls with data parameter set to ‘null’ was causing this to happen. Simple solution for me was to set ‘{}’ as data parameter value instead of ‘null’. Moreover, You can change method that I already mentioned about, postJSON with this fix:

$.postJSON = function(url, data, callback) {
     if(data == null)
         data = {};
     $.post(url, data, callback, "json");

BTW I already use Firefox 3.5 during development - it consumes less resources than previous versions () so I strongly recommend upgrading to newest version.

comments powered by Disqus