简体   繁体   中英

Ajax request breaks response body?

I'm baffled trying to get this to work properly. I'm using jQuery 1.10.3 to attempt retrieval of a JSON-encoded object. This request should normally be fulfilled by a php script, which (when visited directly) returns it correctly (at least, to the human eye). However, when I use a jQuery request to fetch it, I end up with a ton of garbage that jQuery can't parse. It looks like so:

��VQo�6~N�

When it should look like this:

{"227382":[{"id":"1593515742","type":"household",

What am I doing wrong here?

PHP source of the request proxy: http://pastebin.com/hYcb1L2Z Line that inits the jQuery ajax request: $.getJSON( "proxy.php?Action=GET&Url= https://somesite.com/getsomeJson&lang=eng " )

For some reason the proxy.php script wasn't passing along the

Content-Type:application/json;charset=UTF-8

header. Fixed that and all is working much better!

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