跨域的jQuery Ajax请求

跨域的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