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.

9 Responses to “Expected identifier, string or … - say what?”

  1. IE7 Error: Expected identifier, string or number | favrik. Waking up… » Blog Archive Says:

    […] For the win! […]

  2. Sam Says:

    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.

  3. kris Says:

    thanks! saved a few hairs on my head!

  4. sunil Says:

    Dude..!!
    Thanks, ur tips just worked awsome…I spotted the culprit in no time!!!

  5. Bryan Says:

    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!

  6. jay Says:

    COOL..thanks…I also saved some hair :-)

  7. Jinn Nguyen Says:

    Good one

  8. Paul Huntsberger Says:

    Thank you so much for finding this answer - I was going crazy trying figure out where the problem was! KUDOS!

  9. Will Says:

    Great, thanks.

Leave a Reply