Expected identifier, string or … - say what?
9 Responses October 4th, 2007 | Ekerete.
While working on a recent project with the excellent Prototype and Scriptaculous javascript libraries, I came across a frustrating error in IE7 (and I’m sure IE6 although I didn’t test it). The page worked beautifully in firefox but came up with “Expected identifier, string or number” on IE.
Normal debugging procedures (firebug, web developer toolbar) failed to show where my error was. To its credit, the Microsoft script debugger actually showed me the function with the error but at that time I didn’t see it as an error. After a couple of hours of hair-pulling and googling, I came across this post.
Apparently, a comma in my function was the culprit. My problem code was:
function xajax_getOptions(badgeId) { new Ajax.Request($F(“absolute-url“) + “/ajax/options“, { method:‘post‘, parameters: {catid: badgeId}, onSuccess: function(transport){ var response = transport.responseText; $(“badgecell“).innerHTML = response; getBadgeImage(); }, //onFailure: function(){ alert(”an error occurred”); } }); }
Notice that I commented out the onFailure parameter without taking out the comma at the end. Firefox ignored that, IE choked.
A big thank you to Khlo for showing the way.




November 30th, 2007
[…] For the win! […]
January 26th, 2008
And thanks very much in turn to you for writing this post that saved me from going crazy trying to figure this out for myself.
February 4th, 2008
thanks! saved a few hairs on my head!
February 29th, 2008
Dude..!!
Thanks, ur tips just worked awsome…I spotted the culprit in no time!!!
February 29th, 2008
I agree, thanks a TON for leading the way. I had a similar problem where my code worked in FF but not IE. Turned out my problem was using the attr “class” instead of “className” - worked in FF but not IE.
Thanks!
March 27th, 2008
COOL..thanks…I also saved some hair
April 17th, 2008
Good one
April 18th, 2008
Thank you so much for finding this answer - I was going crazy trying figure out where the problem was! KUDOS!
May 5th, 2008
Great, thanks.