【发布时间】:2012-12-28 13:50:04
【问题描述】:
我正在尝试使用 isoHunt 搜索 API,但是当我尝试解析 URL(在我的浏览器中查看其位置后似乎是正确的)时,什么也没有发生。下面是我用来尝试和测试脚本的脚本。有谁知道是什么原因导致无法解析 JSON 文件?
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>isoHunt Search</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#button").click(function(){
var keywords = $("#keywords").val();
var url = "http://isohunt.com/js/json.php?ihq=" + keywords;
$("#output").append(url);
$.getJSON(url, function(data){
$("#output").append("TEST123");
});
});
});
</script>
</head>
<body>
<input type="text" name="keywords" id="keywords" />
<button id="button">Search</button>
<div id="output"></div>
</body>
</html>
【问题讨论】:
-
Same Origin Policy 今天不是你的朋友。
-
有什么办法可以使这项工作,或者由于同源政策,我试图做的事情的总体思路是什么?
-
这里很烦人的是,Isohunt 返回的 JSON 响应为 contentType
text/plain;charset=utf-8。
标签: jquery json api parsing search