Pages

Search This Blog

Sunday, November 25, 2007

Expected identifier, string or number

invoice software
Invoice software

For below javascript code, i got error "Expected identifier, string or number" in IE but it's working fine in firefox and safari.
var RealtimeViewer =
{
timer : 5000,
Interval : null,

init: function() {
xxxxxxxxx
xxxxxxxxx
},

RatingUpdate: function(){
xxxxxxxx
xxxxxxxx
},

};
To solve the problem, remove the last "," before close the object RealtimeViewer "};". It will become

var RealtimeViewer = {
timer : 5000,
Interval : null,

init: function()
{
xxxxxxxxx
xxxxxxxxx
},

RatingUpdate: function()
{
xxxxxxxx
xxxxxxxx
}
};

59 comments:

Unknown said...

mate... you just solved a problem I'd spent two days working on. Champ!

Levi said...

Same here!!
I think it's dumb that IE assumes a new string just because you had a comma, but THANK YOU for sharing the solution!!

Dang... I can't believe it consumed me... and it was so simple!! GAHH :|

Anonymous said...

Thank You. Thank You. Thank You.

Unknown said...

lol, that was so simple, hahaha

Anonymous said...

thank you! luckily for me (and others, it appears), this entry is the first hit on google when you search "expected identifier string number"

thanks again

Anonymous said...

Thanks , that was a great help.

Anonymous said...

Thank you so much, you just saved me hours of pain.

Jessie Berlin said...

Thanks so much! You just saved me hours of debugging.

Greg said...

Wow... first result on google and my problem is solved (even though its unrelated, it was that stupid comma)

thanks heaps :)

Amit Shah said...

Im getting same error in prototype.js but didnt get "," before closing last }. Do you have any idea about that.

In blues said...

Hi Amit, can post ur code to me? thanks

Amit Shah said...

Hi blue,

I have solved that problem. Problem was not with prototype.js but with another js file.

Thanks

Anonymous said...

Another mind brought back from the edge of IE-induced insanity. Thank you!

Sarfaraz Ahmed Soomro said...

Thank you. It helped a lot. While trying to debug the problem, i never did even had a hint that it would be because of a this :-s

Hein Tore Tønnesen said...

THANK YOU!

Anonymous said...

thank you!!! :) stupid internet explorer is driving me crazy!!! thank you again for sharing this extremely quick fix!

Anonymous said...

Nice thanks a lot firstr search in google and its solved , sounds amazing

Anonymous said...

saved me, man

Anonymous said...

Man, youre the king!

This weird messege is also caused by an ending comma in an json feed!

Unknown said...

Behold my brothers and sisters.

http://www.jslint.com/

Never again will you suffer at the hands of such a simple mistake.

hans said...

Great Catch! Also I notice that using reserved words as method names will produce the same error (at least when constructing classes in mootools). So for example...

var MyClass = new Class({

delete: function(){
//code
}

})

Anonymous said...

Thanks for posting the fix.

Unknown said...

thanks a lot....
simple and effective solution..

Sam Stone said...

Thanks man... lifesaver!

Now if only I could get jwplayer to work in IE.

johndbarnard said...

I feel so stupid but thank you so much - if only I had thought to remove the last comma 2 hours ago!

Anonymous said...

Tanks mate! I will now be able to brag with my error free site!

weicool said...

Thanks a lot! This saved me lots of frustration!

Gabriel Harper said...

Nice simple solution - hard part for me is finding where the stupid error comes from in the first place! The IE dialog box tells the line number and character position but remember this is the line relative to the JS file being executed.

Karl said...

Well, you didn't save the the "hours of pain," but I'll still give you the thanks!

OMFG, if IE just specified which GD file it thought the error was in, I'd be gulping cervezas by now. Ugh.

Anonymous said...

God I hate trying to write JS for IE. You're my hero

Anonymous said...

Thanks for this explanation, it saved me some time!

Claudio

Anonymous said...

Worked a treat!

Anonymous said...

Please don't ever take down this post! You saved the last shreds of my sanity :)
Stupid IE. I don't even care that it caused an error in the lame-@ss browser... why can't they provide an error message that actually means something?!?!?!

Thanks again!

pipicoms said...

you saved the day.. Thanx!!!!

Unknown said...

I just ran into this myself, and your post was exceedingly helpful. Thanks!

James said...

Thank God this is the first entry on Google! and thank God you put up this post :)

Anonymous said...

ty, i was freaked out when it didn't work in ie and glad when it turned out to be such a simple fix.

Anonymous said...

Thank you for the fix. Googled the IE error and BLAME!
Can't thank you enough.
Thank you. Thank you.

intrudah said...

much obliged.

Anonymous said...

2 years after posting this article, its still helping people out.

Thanks for the info - and for potentially saving me hours of debugging (which with IE is like p*ssing in the dark).

Alexxandar said...

Thank you...
Its a simple problem, but solution is not so obvious. ;)

Unknown said...

Thanks this really helped out.

twig said...

brilliant!
i cannot thank you enough!

Anonymous said...

Thanks a lot for sharing this. That saved me a lot!
Isaac

Jenn said...

Thank You! Thank You! I already hate IE, but you saved me from cursing it even more.

MichaelLeeBaker said...

DAAAANG. I can't believe that was it.

Justin Meighan said...

Thank you for sharing this.

Now i'm no IE fan...and gawd knows I love bashing it, but if there are no more params then the last , is not needed, and is in fact wrong!

Anonymous said...

IE 6 rage alert... hehehe
Thanx for the heads up! Pointed me right at the b@stard extra comma!

Anonymous said...

thanks very very useful

Anonymous said...

THANK YOU!! I spent *hours* trying to figure out why IE was throwing this exact error in a jQuery statement. It turns out the cause is the same, although in this particular case it was in an ajax list of key/value pairs. The last key/value pair ended with an extra comma. Removing it was the fix. Thanks again for posting this!

Glen said...

Thanks!! Would have never figured this out on my own. It's always IE, even with IE 6 phasing out, it's still always IE!!

Anonymous said...

THANK YOU!

Kal said...

What ever would we do without Google… and the good souls who post their solutions for the rest of us. I hadn't yet spent hours trying to figure this out, but I'm sure I would have. Many thanks!!

Unknown said...

Another "thanks"!

BTW if anyone else has this problem while trying to configure CKEDITOR (I've been pulling my hair :-)

As of 1/13/2011 the online document at http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html has a long list of example config statements, and many do not enclose the reserved word class in apostrophes, which results in this SAME ERROR MESSAGE. So if you copy from that documentation, you need to update the code to 'class' (see comment from Hans on Feb 09 in this forum.)

Gabrielle Scanlon said...

Saved my butt thank you!

If anyone is configuring JWPlayer and is using the Google Analytics Plugin - beware if it is the last line:

plugins: { gapro: { accountid: 'UA-202715-21' } },

Which should be of course:

plugins: { gapro: { accountid: 'UA-202715-21' } }

Crazy thing is that it works fine in FireFox, Safari, IE9 ... but not IE8 so it took me a while to catch.

How do they manage to do this STILL at Microsoft?

Thanks soooo much for posting this.

In blues said...

thanks Gabrielle, for sharing your experience here.

Mayur bhuva said...

thanksss........

Sunil said...

Super dooper dooper... Man why did they even build an IE. Please ask the microsoft guys to just buy of firefox and stop creating IE browsers any more...

Anonymous said...

This is insane. Who puts extra comma before ending a bracket? "}"

there must be something wrong with firefox and safari that do not have problem with that.

{a,b, c,} is a syntax error.

looks like this is a page of dummies :)