简体   繁体   中英

Phonegap IOS app, JSON parse error?

I am generating a json object from php with json_encode and consume it with JS. The JSON object is valid, i run it through JSON lint, but I am always getting a parseerror when it is consumed from the php file directly.

Now, if i generate a .json file and output the object there no error is raised.

Has anyone come across this problem? Any thoughts as to why this might be happening?

Thank you. Any help is greatly appreciated.

Try not passing the JSON object to the JS file but instead echo it out on the php file then tell js in an output function of some sort to pick it up1

eg echo json_encode // In php file

function(output){ ('some element').html(output); //output is what is returned from the php file (the json) }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM