The HTTP Status 122 Error in IE7 in Ajax Apps

by barce on September 5, 2008

Summary: Don’t use the GET method in Ajax Apps, if you can void it, because IE7 craps out with more than 2032 characters in a get string.

Here’s the page that craps out at 2033 characters with IE7:

You won’t see the error with other browsers.

Here’s the page that’s okay:

What’s going on here?

picture of http status 122
Sometimes you’ll write a piece of Javascript that uses prototype and looks like this:

  var url = '/status122/listener/?stuff=' + encodeURIComponent($('js_stuff').innerHTML);

  // This is where we send our raw ratings for parsing
  var ajax = new Ajax.Updater(
		method: 'get',
		onComplete: showResponse

If you print http.status you get an HTTP Status of 122. WTF?

What’s going on here is that IE7 sets a limit of 2032 characters on GET strings, so you have to do a POST instead like so:

  var getvar = encodeURIComponent($('js_stuff').innerHTML);
  var url = '/status122/listener/';

  // This is where we send our raw data for parsing
  // If we use method: 'get', IE7 will return a 122, but
  // b/c Firefox is RFC2616 compliant and realizes that
  // there is no minimum length for a URI, we get success.
  // Here we use method: 'post' b/c IE7 is lame.
  var ajax = new Ajax.Updater(
		method: 'post',
		postBody: 'stuff=' + getvar,
		onComplete: showResponse

I hope this helps.

What Ajax quirks have you run into?

{ 9 comments… read them below or add one }

Robert Bailey May 14, 2009 at 8:20 am

Thanks for this, I have been looking at why this is happening with IE7 for a few hours.

Henry November 3, 2009 at 10:48 pm

Nice program and explanation ! Very useful !

Stuart March 3, 2010 at 8:34 am

Thanks – this was helpful. With IE6, was the point of crapping out even less than 2032 characters?

barce March 11, 2010 at 1:27 pm

Hi Stuart, thanks for reading my blog. I haven’t tested with IE6. I’d be interested to know if it does crap out at less than 2032 characters.

fabio April 21, 2010 at 6:46 am

you’re tha man.

many thanks

Phanindra June 17, 2010 at 10:12 pm

Great! I was wondering why I get an error page for my app in IE7 only when I do a GET! Thanks for the tip!

MalekO September 14, 2010 at 11:45 pm

Thanks ! this helped me understanding what happened, because it worked with me and not with my collegue … he used IE7 !
A great job !

Russell England November 8, 2010 at 7:39 pm

absolute star!!!! I’ve been trying to figure this out for 9 solid hours…. thank you thank you thank you

Fabio January 24, 2012 at 6:12 am

Hey man , many many many thanks, i was going literally mad !!!!!You saved my life

Leave a Comment

Previous post:

Next post: