IE7 expected a string, identifier or number

JSON is nice to read. It’s also nice when parsers are for­giv­ing, but here we are.

I just spent ages chas­ing [what I thought was] a bug using $.getJ­SON in IE7 that turned out to be an issue with some­thing else entirely.

If you’re using $(el).css or .ani­mate with JSON, make sure you’ve ter­mi­nated all items cor­rectly and don’t have any hang­ing com­mas left over:

Hanging comma at end of JSON params

This case sent me par­tic­u­larly crazy as I was also deal­ing with an actual JSON request in the same gen­eral vicin­ity that I’d val­i­dated a bunch of times and seemed perfect.

Note to self: Before you go down the white­space and text encod­ing rab­bit­hole next time, make sure you’re actu­ally check­ing the right JSON!

Tags: , , ,

posted on Thursday, April 19th, 2012 at 9:37 am by Josh Street, filed under General.

2 Responses to “IE7 expected a string, identifier or number”

  1. Michael says:

    A sim­i­lar thing seems to hap­pen with PHP arrays.

    One day it works, the next it throws an error and the page doesn’t load.

    WEIRD!!!!

    Clearly it was aliens….

  2. Sam says:

    Seems you have a cer­tain love/hate rela­tion­ship with a guy called Jason…

Leave a Reply