Hi guys, I've pulled data from a database with a callback function, but the data sent back is a string something like this: John Doe Code (markup): And I've got this error: Uncaught ReferenceError: John Doe is not defined at... Code (markup): So according to this link: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Not_defined It says that the result is a variable. So I've to declare a variable, but how to do that? I've been thinking of some thing like this and it isn't work: var backData = "var backdata = '" + result[0].name + "'"; Code (markup): Thank you,
String concatenation in PHP is not with "+" but with "." operator, so perhaps that should be like following? $backData = "var backdata = '" . result[0].name . "'"; PHP:
Finally, I got it done: var backData = "var backdata = '" + result[0].name + "';"; Code (markup): Just one semicolon can ruin your day.
Aw, didn't think of that; I'm still reluctant to follow node.js development. I will, someday. Anyways, it's good to know a valid piece of it from you
You should. So when I get struck I'll have someone helped me Beside from that, it's the only platform I'm exciting about.
Just a warning, single quotes are technically invalid in JSON, so depending on how you're dealing with this you'd want to consider: var backData = 'var backdata = "' + result[0].name + '";'; Code (markup): One of the biggest reasons I favor using single-quotes in my codebases, so many things want double quotes in the output. That said, I'm wondering why you'd be building client-side code server-side. Doesn't seem kosher.
Thank you @deathshadow, that would be helpful. I use node.js since it came out. Happens to love the platform. I work mostly with real time data and streaming. In the old days these can be possible only with opencv and java applet. When node.js came out you don't need three or four platforms to do the job. Just two. (I never code in Flash.) Now it can be done with only one platform. Data is scant though. You have to try and error to slowly crawl forward. Maybe C or C# can be better. But I know no C. People love exploring right?