PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Wed Jun 26, 2019 8:05 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Issue with JSON string
PostPosted: Wed Feb 03, 2016 10:05 am 
Offline
Forum Newbie

Joined: Tue Jan 26, 2016 9:31 am
Posts: 4
I'm trying to use Dojo to make an Ajax call to a php program that returns a result set. I can see the json string in PHP Netbeans debugger just fine, but when it comes back to my script, the response is returning an Unexpected Token :. I think this means that it's seeing a colon (:) in the wrong place. The only thing I can think of is the PHP program is returning the JSON string wrapped in double quotes, which is throwing off the parser. When I copy the string from the Netbeans debugger and put it into JSONLint, it errors, but when I remove the outer quotes, it validates fine.

Funny thing is that if I call the php program that generates the JSON directly and just echo the results to the browser, I don't see the quotes.

Any Ideas on how to debug?

Thanks in advance.


Top
 Profile  
 
PostPosted: Wed Feb 03, 2016 1:40 pm 
Offline
Site Administrator
User avatar

Joined: Wed Aug 25, 2004 7:54 pm
Posts: 13590
Location: New York, NY, US
Quote:
The only thing I can think of is the PHP program is returning the JSON string wrapped in double quotes, which is throwing off the parser. When I copy the string from the Netbeans debugger and put it into JSONLint, it errors, but when I remove the outer quotes, it validates fine.

Funny thing is that if I call the php program that generates the JSON directly and just echo the results to the browser, I don't see the quotes.

You need to find out where the quotes are coming from. I suspect that you are adding them somewhere. And by quotes around the JSON, I am assuming that you mean something like ' "{ foo: "bar" }" '.

_________________
(#10850)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group