I don’t know if this is a problem in other libraries, but I suspect it is. But I do know that it’s happened to me when using jQuery’s Ajax functions.
Why is this occurring?
I was tormenting myself with this same question on a client project, and discovered that although a bit of browser quirkiness was involved, it was actually an error on my part.
I hate it when it’s me. ;)
As it turns out, I had an extra trailing comma at the end of the last element in my array. For example, in the following array:
{“gamesImDroolingFor”:[{"developer":"Blizzard","title:"Diablo III"},{"developer":"Square Enix","title":"Final Fantasy XIII"},]}
You’ll notice that there’s a comma after the last game’s bracket (which has been turned red for emphasis).
Firefox will ignore that comma, since clearly there’s no new object after it. Internet Explorer, the special child of the web, isn’t quite so bright, so it adds an extra, blank element to the array it creates.
Go IE.
The solution is easy, of course. Remove the unneeded comma.
I hope this helps prevent other developers from driving themselves batty trying to figure out what’s going wrong with their own arrays.
]]>