View Full Version : JSON returns 'invalid label' error...please help..

01-30-2009, 08:13 PM
I am returning the following JSON data from a PHP Script:

Nicholas","entered_on":"01\/30\/09 11:01 AM"},"1":{"file_num":"MYFILE2","room":"305","box":"ZGB123456"
,"name":"Thiago Barbedo","entered_on":"01\/30\/09 11:01 AM"}}

I am then parsing this data in JavaScript with eval....

var objResponse = eval("(" + data + ")");

When this processes, I get an 'invalid label' error in Firebug but the results still return and I can access the data with no problems. However, I would like to remove this error from my code.

Can someone please guide me in the right direction? I have been looking for a solution for the past hour and all of the posts that correspond to this error suggest missing parens in the eval statement, however this is not the problem here....

Thanks in advance..

rnd me
01-30-2009, 09:19 PM
there seems to be a line break in "Gary Nicholas" that's causing the problem.

01-30-2009, 09:52 PM
The line break is there because of the code window...the break doesn't appear in the actual data.

However, I have found my error. The reason why it was returning the 'invalid label' syntax is because in the AJAX Request the dataType parameter was defined as 'script'. This was bringing the response back as text rather than pure JSON which was causing that error.

All I have to do is remove the optional dataType parameter or change 'script' to 'json'

Thanks for trying to help though!

01-31-2009, 08:21 AM
one more thing. DO NOT USE eval EVER. See on crockford's site http://javascript.crockford.com/code.html


02-17-2009, 08:06 AM
I am a newbee to JSON. Could you please give me the links for learning basic JSON stuff, like from Simple examples to creating our own JSON.
Help will be really appreciated.
pls mail: vikasg18@gmail.com


04-27-2009, 10:57 AM
could u pls send me the links to learn JSON?