开发者

Making JSON Feed Work Server to Server

I have a JSON feed (which I don't directly control, I have to ask the server admins to update it), that is returning NULL, or otherwise not working when I try to access it from another server. The actual feed works fine, but I can't开发者_开发问答 get it to work like a normal API.

Why can I use Flickr, WhitePages, Twitter, etc's JSON APIs, but for:

http://portlandoregon.gov/shared/cfm/json.cfm

It returns NULL in the browser when using JS. If I call it on the same server, it's fine though.

If this is a server issue, what do I ask the admins to change, and if this is a local (browser) based issue, what am I doing wrong for this one feed that works for every other JSON API?


They have set the content type to text/html instead of application/json. So if you're using jQuery $.ajax or $.get instead of $.getJSON, then you need to instruct it to handle it as application/json so that it will automatically parse it as JSON.

On the other hand, if really no data is been returned, then they are maybe checking who/what is requesting it and blocking it. The only resort is indeed to contact them. It might be a bug, or it might be awarely builtin to prevent leeching.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜