在外部服务器中访问JSON [英] accessing JSON in external server

查看:94
本文介绍了在外部服务器中访问JSON的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有外部json URL.

I have external json URL.

http://kun6858.iptime.org:8080/apps/list/?app_mb_no = 9

然后我用jquery $ .getJSON(..)

And I access this json with jquery $.getJSON(..)

<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<script>
$.getJSON(
    "http://kun6858.iptime.org:8080/apps/list/?jsoncallback=?",
    {
        app_mb_no : 9
    },
    function(data) {
        console.log(data);
    }
);
</script>
</body>
</html>

但是我无法使用上述源访问JSON.

But I can't access the JSON using above source.

我不知道如何访问外部服务器的json. 我的消息来源有问题吗?还是JSON?

I have no idea about how to access external server's json. Does my source have problem? or the JSON?

仅供参考,这是屏幕截图.

for your reference, this is screen shot..

推荐答案

您需要使用JSONP进行跨域访问.因此,您必须修改AJAX调用.

You need to use JSONP for cross-domain access. Therefore, you have to modify your AJAX call.

在此情况下,有一个很好的解释:

An good explaination for this scenario is here:

http://www.jquery4u.com/json/jsonp-examples/

这篇关于在外部服务器中访问JSON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆