javascriptとjQueryを使用してAPIにアクセスしようとしていますが、奇妙なエラーが発生します。
$(document).ready(function() {
var server = 'https://' + rand(10) + '.spotilocal.com:4371';
$.getJSON(
server + "/service/version.json?service=remote&_=" + new Date().getTime(),
function(data) {
if (data.version == 9) {
$.getJSON(
server + "/simplecsrf/token.json?&cors=&_=" + new Date().getTime(),
function(data) {
console.log(data.toString());
});
}
});
function rand(length,current){
// returns a random string
}
});
私のエラー:
XHR finished loading: "https://rwhpxmubmi.spotilocal.com:4371/service/version.json?service=remote&_=1337093238805".
XMLHttpRequest cannot load https://rwhpxmubmi.spotilocal.com:4371/simplecsrf/token.json?&cors=&_=1337093239623. Origin http://example.com is not allowed by Access-Control-Allow-Origin.
最初のリクエストは成功しますが、2番目のリクエストは失敗します。ただし、両方のファイルは同じサーバー上にあり、両方のファイルはJSONです。
なぜこのエラーが発生するのか、そしてそれを修正する方法を誰かが知っていますか?