简体   繁体   中英

Changing servers, and getting SyntaxError: JSON.parse: unexpected character parsererror

I'm moving php code from one linux server to another, and the new one is producing rubbish.

In Firebug, the first result looks great, like normal json encoded values, and works.

The second result (new server) is preceded by "html" and "body" tags, a "p" tag, and then "quot;" instead of actual quotes around the data (sorry, I couldn't get the form to display all that), and throws an error.

In both cases, the code is the same, the output an array passed through json_encode.

Could this be a configuration error?

Thanks in advance.

John

Well, ultimately I added header('Content-type: application/json'); which removed the encoded html. I'd sure like to know why I had to do that.

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