-2

I'm having a problem (see 2 screenshots):

1

2

The problem is "SyntaxError: identifier starts immediately after numeric literal"

This data im trying to send through the ajax script is html, right? Because it says data-type: html.

What is an identifier? Why is the problem at the -4d and not the -50 preceding it?

If I remove the dashes, there are no problems. If I add quotes around the string, there are no problems. But I can't use these two solutions. I need the string as-is.

Help! This has been driving me crazy. Can't seem to come up with a solution. Thanks in advance!

Community
  • 1
  • 1
Lv99Zubat
  • 853
  • 2
  • 10
  • 27
  • The quotes won't affect the contents of the string, they define the string. What you're doing now is being interpreted as a named token, but it's illegal (you can't have hyphens in tokens) and so it's breaking. – Xophmeister Dec 07 '12 at 15:44
  • 1
    The reason that `c7a0e2f7` and `5046` doesn't cause any error when parsed is that the first could be a variable name and the second could be a number, but `4da5` wouldn't work as either a variable name or a number. – Guffa Dec 07 '12 at 15:46
  • So youre saying $_SESSION['emailAcceptLinkOrgId'] is being treated as the name of a variable? hmmm thanks, that helps. But I'm still kind of confused because the other variables in the data are not surrounded in quotes. So that's something I'm still thinking about. – Lv99Zubat Dec 07 '12 at 15:55
  • Btw guys thanks for the downvotes. I put in about 8 hours worth of research time to figure this out. Guess that wasn't enough. This community is awesome. Really gives new programmers a resource they can count on. Oh wait, I'm banned from asking questions now. Nevermind. – Lv99Zubat Dec 07 '12 at 19:22

3 Answers3

0

String value in JavaScript should be surrounded with quotes:

// --------------------v                                    v---
echo 'emailAcceptLink: "' . $_SESSION['emailAcceptLink'] . '",';
VisioN
  • 143,310
  • 32
  • 282
  • 281
0

Surround your variables with "" :) so

echo 'email: "'.$email.'"';
0

You need to add quotes (single/double) around the values for emailAcceptLink and emailAccesLinkOrgId.

krasenslavov
  • 355
  • 1
  • 4
  • 14