【问题标题】:isoHunt JSON search API for torrents not working用于种子的 isoHunt JSON 搜索 API 不起作用
【发布时间】: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 不支持JSONP,你也许可以使用YQL
  • 这里很烦人的是,Isohunt 返回的 JSON 响应为 contentType text/plain;charset=utf-8

标签: jquery json api parsing search


【解决方案1】:

由于某种原因 (read here) isohunt 不支持 JSONP,所以你不能在这里使用 ajax 跨域。但是您可以在您的域内创建代理

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-09-11
    • 1970-01-01
    • 1970-01-01
    • 2018-06-05
    • 2015-10-12
    • 2019-08-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多