跨域的jQuery Ajax请求 [英] cross domain jquery ajax request

查看:125
本文介绍了跨域的jQuery Ajax请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发送Ajax请求的URL http://json-cricket.appspot.com/ score.json 由code

I am sending ajax request to a url http://json-cricket.appspot.com/score.json by the code

var url="http://json-cricket.appspot.com/score.json";
$.get(url, function (data) {
    console.log(data);
}, 'json');

和这是行不通的,但如果我加上'?回调=?的网址,然后它会奏效。即。

and this is not working, but if I add '?callback=?' to the url, then it will work. i.e.

var url="http://json-cricket.appspot.com/score.json?callback=?";
$.get(url, function (data) {
    console.log(data);
}, 'json');

然后,它会正常工作。

Then it will work.

这两个网址会给输出。只是不同的是后者将包裹的结果对?(结果)

Both url will give the output. Only the difference is the the latter one will wrap the results on ?(result).

有关我的知识,任何人都可以解释我发生了什么事?它是从这里

For my knowledge, can anyone explain me what is happening? It was taken from here.

任何一个环节做进一步的研究将是非常美联社preciable。

Any link for further study would be highly appreciable.

推荐答案

这是因为它是一个跨域Ajax请求。

It is because it is a cross-domain ajax request.

有关更多信息,你可以看看维基百科的文章 http://en.wikipedia.org/wiki/ JSON#JSONP

For more info, you can have a look at the wikipedia article http://en.wikipedia.org/wiki/JSON#JSONP

这篇关于跨域的jQuery Ajax请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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