Parse live stream HTTP chunked transfer JSON with jQuery?

自闭症网瘾萝莉.ら 提交于 2019-12-24 10:01:05

问题


Here is live HTTP stream that delivers streaming JSON objects using chunked transfer encoding: http://stream.meetup.com/2/rsvps

Is it possible to parse this JSON request using jQuery getJSON ? I want to get each item as it comes in and insert new image tag with the image. Like the function I wrote below, but doesn't work


$.getJSON("http://stream.meetup.com/2/rsvps", displayImages);

function displayImages(data) { $.each(data.results, function(i,item) {

$("<img/>").attr("src", item.member.photo).appendTo('#images'); });

}


回答1:


You cannot make cross-domain ajax requests due to the same origin policy. You can use JSONP to sidestep the problem, but the web service needs to support it.

It looks like the Meetup API supports JSONP, though naturally JSONP can't handle streaming-style updates.



来源:https://stackoverflow.com/questions/5927932/parse-live-stream-http-chunked-transfer-json-with-jquery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!