Home > web development > Firefox 3.0: 411 Length required with JQuery

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 and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Technorati
  • DotNetKicks
  • email
  • Reddit
  • Twitter

Related posts:

  1. Tips for jQuery validation plugin
  2. $.postJSON – how to avoid JSON attack
Categories: web development Tags: , ,
  1. Alfredo
    September 4th, 2009 at 06:14 | #1

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

  2. September 7th, 2009 at 08:30 | #2

    I am glad I could help

  3. khan
    October 29th, 2009 at 08:48 | #3

    Saved my butt. Thanks.

  4. October 29th, 2009 at 11:56 | #4

    You’re welcome

  5. scott
    January 27th, 2010 at 13:13 | #5

    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
    June 1st, 2010 at 08:30 | #6

    Saved my day :)

  1. No trackbacks yet.