我正在尝试从http://status.mojang.com/check获取数据,但我没有收到任何数据。但是,我在响应标签(谷歌浏览器)中获取数据
我在网络服务器上运行它来测试它,我也试过本地。
这是我的代码:
$.getJSON("//status.mojang.com/check?jsoncallback=?", function(result) {
console.log(result);
});
感谢任何帮助
答案 0 :(得分:0)
根据jquery帮助页面(http://api.jquery.com/jQuery.getJSON/),
This is a shorthand Ajax function, which is equivalent to:
$.ajax({
dataType: "json",
url: url,
data: data,
success: success
});
当您访问外部URL时,您需要将您的请求作为jsonp调用发送,以便绕过access-control-allow-origin标头。这意味着dataType
需要是“jsonp”