Javascript JSON BTC/LTC ticker不再工作
上个月我一直在使用这个JSON代码。它一直很有魅力,但今天它停止了工作;也许有人知道这里出了什么问题Javascript JSON BTC/LTC ticker不再工作,javascript,jquery,html,json,bitcoin,Javascript,Jquery,Html,Json,Bitcoin,上个月我一直在使用这个JSON代码。它一直很有魅力,但今天它停止了工作;也许有人知道这里出了什么问题 $(function () { startRefresh(); }); function startRefresh() { setTimeout(startRefresh, 10000); var turl = 'https://btc-e.com/api/2/ltc_btc/ticker'; $.getJSON('http://query.yahooapis.
$(function () {
startRefresh();
});
function startRefresh() {
setTimeout(startRefresh, 10000);
var turl = 'https://btc-e.com/api/2/ltc_btc/ticker';
$.getJSON('http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20json%20where%20url%3D%22' + encodeURIComponent(turl) + '%22&format=json', function (data) {
jQuery('#ticker').html(data['query'].results.ticker.last);
jQuery('#ticker').append(' BTC');
});
}
下面是相同的示例,但使用Cryptsy API,效果良好:
我签出并获得了JSON,因此问题不在于该站点
我检查了你的代码,除了有点脏之外,没有任何东西可以阻止它使用该服务
因此,问题似乎在雅虎方面。Purhaps表示,雅虎不再提供API
我已经清理(并注释)了您的代码:
然而,您确实应该从服务器端代码(如PHP)中提取RESTAPI。除非它们在中可用,或者它们并非真正用于跨域客户端脚本
我希望这有帮助 哦,看,在你的控制台里。。。错误消息。这与jsonp有关吗?BTC-E是否可以更改API中的某些内容?
// Function for pulling JSON
function startRefresh() {
// This is the API URL
var turl = 'https://btc-e.com/api/2/ltc_btc/ticker';
// This sends the API URL through Yahoo?
$.getJSON('http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20json%20where%20url%3D%22' + encodeURIComponent(turl) + '%22&format=json', function (data) {
// Writes to the page
$('#ticker').html(data['query'].results.ticker.last+' BTC');
});
}
// Do the initial pull
startRefresh();
// Refresh every 10000
setInterval(startRefresh, 10000);