I am trying to return a simple JSON response from PHP on server. The JSON response seems to be formatted correct - I've validated it, but for some reason I am getting
Uncaught SyntaxError: Unexpected token :
error and my store fails to load.
I've tried setting content type to application/json as mentioned in many forums.
hi guys, I was able to get the Response Content-Type to be in applicaiton/json MIME type. But still running into this error- JSON is valid- this is driving me nuts,
folks..it finally worked. being a newbie, every step seems to be a challenge, - but thanks to helpful posts on the web.
here is what I had to do...
After getting the MIME type straight.
I changed the code to implement callback as it is JSONP
echo json_encode(array('sb3m'=>$arr)) // this may be valid for a JSON response.
to
echo $_GET['callback'].'('.json_encode(array('sb3m'=>$arr)).')'; // key here $_GET... as this handles JSONP requests from a different server than responding server.