开发者

getJSON function always returns null

I am trying to make a get http request using jquery getJSON function. I have implemented it like this...

<script type="text/javascript">
$(function(){
$("#query").keyup(function(event) {
        keyword = $("#query").val();
        $.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?tags=cat&tagmode=any&format=json&jsoncallback=?", showdata );
    });
});
function showda开发者_运维问答ta(data, status) {
    alert(data + ":" + status);
}
</script>

This always returns null. I have checked the HTTP Headers, they are null as well. But if I directly use the URL, it displays JSON in the browser window.

What am I doing wrong?

Some suggested I should use JSONP, but in the URL I will actually using, there is some sensitive information which I don't want to reveal, so I want to stick with getJSON.

Regards


@Reigel - no its not on the same domain.

your problem is because of the same-origin-policy


As @Reigel suggested the problem was of same-origin-policy, so I have decided to create a proxy by using a server-based code which returns the correct json.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜