Syntaxerror: Identifier Starts Immediately After Numeric Literal In Firebug
I'm getting that error when I call this javascript function: function kickUser(id_userChat){ $.post('chatFuncs.php', { action: 'kick', id_user: id_userChat }); } this 'kickUser'
Solution 1:
Identifiers in JavaScript can't begin with a number; they must begin with a letter, $
or _
.
I'm guessing it's coming from this:
onclick="kick_user('.$rowUsers['id_user'].')">Kick</a>
If you mean to pass a string, then you need to quote the value being passed.
onclick="kick_user(\"'.$rowUsers['id_user'].'\")">Kick</a>
I don't know PHP, so maybe you need different escaping, but this should give you the idea.
Solution 2:
The resulting JavaScript code will be
kickUser(userName)
…and obviously there is no js variable userName
. You want to pass a string instead:
kickUser('userName');
So add the quotes/apostrophes to the output, and don't forget to escape the $rowUsers['userName']
properly. It's quite the same for $rowUsers['id_user']
, which seems to have output even an invalid identifier.
Post a Comment for "Syntaxerror: Identifier Starts Immediately After Numeric Literal In Firebug"