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.

Share

Related posts:

  1. Debugging silverlight in Firefox and Chrome
  2. Google Chrome has finally become my first browser!
  3. $.postJSON – how to avoid JSON attack
  4. Tips for jQuery validation plugin
  5. jQuery style Ui dialog over flash banners

8 Responses to “Firefox 3.0: 411 Length required with JQuery”

  1. Alfredo says:

    Thank you very much ! I had the same problem with Firfox 3.0.x.

  2. ITmeze says:

    I am glad I could help

  3. khan says:

    Saved my butt. Thanks.

  4. ITmeze says:

    You’re welcome

  5. scott says:

    Thanks, I ran into this problem too. What’s worse is it’s not reproducible under Cassini, but is under IIS. So if you dev with Cassini, you’ll never notice this error.

  6. max says:

    Saved my day :)

  7. eRez says:

    i’m having the same issue, but when the request is sent from within a flash player, and only when the player is embedded (on facebook wall for example). the thing is i am sending data to the web server but when i check the request via fiddler the request seems to be empty.
    you can reproduce the problem on this page – http://www.facebook.com/beautygeekil?v=wall#!/beautygeekil?v=wall, again only in FF. no issue in other browser, and no issue when the player isn’t embedded.
    can’t find any info about it anywhere.

Leave a Response