【发布时间】:2015-09-17 19:28:59
【问题描述】:
我只是想获取一个 JSON 文件,并在读取它时尝试显示警报。
我的代码如下 http://jsbin.com/winogafoqa/edit?html,js,console
$url = "http://www.googleapis.com/freebase/v1/text/en/bob_dylan?jsoncallback=?";
document.onload(
function() {
$.getJSON($url, function(result) {
alert("success");
});
});
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
</body>
</html>
但我没有收到任何警报消息。 我错过了什么吗?
【问题讨论】:
-
显然会为我抛出错误。请发布有问题的相关代码。我们不应该去现场查看您的代码。问题应该是独立的,并使用演示作为附加组件
-
如果您将网址粘贴到浏览器中,您会得到:
{"error":{"errors":[{"domain":"global","reason":"sslRequired","message":"SSL is required to perform this operation."}],"code":403,"message":"SSL is required to perform this operation."}} -
要查询的 google 需要 ssl 连接。因此,将 URL 更改为 https:// 。查看我的答案以获取更多详细信息
标签: jquery json google-api getjson freebase