Keith Watanabe * NET 2.0

Crappy Firefox/Prototype Bug
By: Keith Watanabe
Published On: 10-13-2007

I just ran into a crappy Firefox/Prototype bug where headers larger than 10kb are dropped.  Other browsers work fine without this limitation (ironically).  It doesn't look like they'll fix this problem.  This really bites!

Well, the solution if you're using prototype is the following.  First upgrade your prototype to 1.5.1+.  You might have to use the beta to get it working.  Next, do not send the JSON data structure as part of the response header from the server.  You have to send it as part of the body.  Use "Content-Type: application/json" as your header.  Then display your data structure.

On the client side, you might have to modify your javascript if you're using Ajax.Request and utilize the convenience methods that automatically serialize JSON.  For instance, if you have a function that looks like:

var ajax = new Ajax.Request(
    url,
    {
       method: 'post', parameters: params, onComplet: someFunction
    }
);

then in your function called someFunction, you probably will need to do something like:

function someFunction(r)
{
    var json =  r.responseText.evalJSON();
   // do something with the json data structure
}

i was using the other form of:

function someFunction(r, json)

so the inbound data structure wouldn't get passed if the size was too big.  this is a pain and hopefully they can address the convenience mode too.  but it was a real pain handling this.

on a similar note, if you upgrade your prototype, you may also have to upgrade your scriptaculous javascript.  Additionally, I ran into a "too much recursion" type of error.  Geeze.

AddThis Social Bookmark Button Sphere: Related Content

Trackbacks: (Trackback URL)

No Comments Posted Yet
September [October] November
Sun Mon Tue Wed Thu Fri Sat
28 29 30 1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31 1