Expected identifier, string or … - say what?
Thursday, October 4th, 2007While 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.



