Sandip's Programming Zen

An attempt to share tech/coding experiences

“Length Required” in Firefox with AJAX POST

with one comment

I have a code which makes Ajax post using JQuery in asp.net. It worked fine in IE and Chrome but failed in Firefox. When debugged using Firebug it showed 411 “Lenght Required” error. After wasting couple of hours on google it finally turned out a kind of Jquery bug.

Normally I wrote code like:

    $.ajax({ type: “POST”,
        url: “URL”,
        dataType: “xml”,
        processData: true,
        error: function(XMLHttpRequest, textStatus, errorThrown) {},
        success: {}
    });

Looks normal and works in IE and Chrome but not in FF, to make work in FF we have to provide an empty data header like below:

    $.ajax({ type: “POST”,
        url: “URL”,
        dataType: “xml”,
        data:{},
        processData: true,
        error: function(XMLHttpRequest, textStatus, errorThrown) {},
        success: {}
    });

It is weird because there are so many other headers which we don’t pass it too and they are taken with default values and why not with data header.

Hope it will be solved in upcoming jquery releases and till then hope this helps.

Advertisements

Written by Sandip

February 14, 2009 at 12:53 pm

Posted in Troubleshooting

One Response

Subscribe to comments with RSS.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: