Internet Explorer Javascript vs Firefox: AJAX Error Recovery in Firefox

After a good 4 hours or more, we finally found the error, it was our bad, but Firefox was helping us, Internet Explorer was keeping the standards but not reporting a warning or recovering from our fault…

We’re currently using a complex ajax call that needs to pass a bunch of variables that have been set on smarty (don’t ask why please)… to make it easy, we decided to do:

$all_smarty_variables = $smarty->get_template_vars();
$jsonString = $jsonEncode->encode($all_smarty_variables);

There’s this thing thats way better than XML to pass information about objects… its called JSON, it’s basically a way for Javascript to serialize its objects in strings, you can send and receive these strings via AJAX requests, and just eval them, or have JSON libraries on your favorite language used on the server side to unmarshall, and re-instanciate the objects that come from javascript.

So… in short words, no need for XML to send and receive objects, no more parsing crap, plus I would say the transfered data is much less. If you don’t think I’m on the right track, monitor the AJAX requests that GMail does, you’ll see some JSON action, or probably a custom implementation of google, they don’t send XML… why do that when you can send objects…

So now that I spent two paragraphs selling you JSON to do your remote procedure calls, I’ll tell you the odity.

As always everything was working fine with us doing our remote call and sending our big ass string in Firefox.

But when we tried in IE, it didnt work.

We tried adding slashes, removing slashes, htmlfying it, you name it we tried it.

After good 4 hours, we found out IE is strict about the size of URL requests done via GET (which makes sense, 1024bytes probably)…
but in any case, our (S)AJAX call worked just fine with Firefox

We went to Sajax.php and saw the following config…

$GLOBALS['sajax_request_type'] = 'GET';

So yeah, we made that a ‘POST’ request type and it worked, it was our bad.

Is this one point in favor of IE for keeping HTTP real? Is this one point in favor of Firefox developers for probably checking the request URL ‘s length before doing an AJAX GET and arbitrarily changing the method to POST?

You decide.
You’re a good geek if you are still reading this, hope you feel me.

Leave a Reply

Your email address will not be published. Required fields are marked *