JavaScript – IE 7 Error: Expected identifier, string or number

This is a common error when debugging JavaScript for the IE 7 and earlier IE browsers. Essentially, it appears that IE 7 is a little more strict on syntax than IE 8 and it's successors.

While this error is not specific to JSON formatted objects, it can occur when they are not syntactically correct. When dealing with JavaScript Object Notation, ensure that you don't have any "trailing commas". For instance, the following will throw an error in IE 7:

var  customLayout: {
            'test1' : [ '0 1 2 3 4 5 6 7 8 9'],
            'test2' : [ 'q w e r t y u i o p'],
}

Whereas, this JSON object is valid (notice that the final element is not suffixed by a comma:

var  customLayout: {
            'test1' : [ '0 1 2 3 4 5 6 7 8 9'],
            'test2' : [ 'q w e r t y u i o p']
}

Subscribe

  • RSS Feed for Posts


This entry was tagged , .

Updated: 2011-12-31

Phil LaNasa

Leave a Reply

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


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <font color="" face="" size=""> <span style="">