Beware jquery $.getJSON on IE

Thu Mar 5, 2009

I usually like simple APIs and interfaces, so I was naturally drawn to the shortcut methods in JQuery – $.getJSON. It didn’t feel right for it to fail quietly, but I put up with it, thinking that I would go back later and change it to $.ajax calls if it really became a problem.

Well, something I hadn’t noticed really until today is that IE will cache the ajax queries from $.getJSON, but FireFox does not. Unfortunately I don’t see a way to pass the cache:false option to getJSON – so as a rule I’m going to default to using .ajax for two reasons:

You can specify whether to cache or not with option cache:false You can specify both a timeout and error callback