getJSON 回调无效
getJSON callback did not work
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<script>
function getprice(){
$.getJSON("https://api.bithumb.com/public/ticker?Callback=?", function(data) {
var price = parseFloat(data['data']['closing_price'])
$('#price').html( price);
});
}
https://poloniex.com/public?command=returnTicker
poloniex 的 url 运行良好。但 bithumb 不是。
如上所说header有错别字,请联系店主。同时,您可以使用 YQL
进行代理请求
function getprice() {
$.getJSON("https://query.yahooapis.com/v1/public/yql?q=select%20*%20FROM%20json%0AWHERE%20url%3D%22https%3A%2F%2Fapi.bithumb.com%2Fpublic%2Fticker%22&format=json&diagnostics=true&callback=", function(data) {
//console.log(data)
var price = parseFloat(data.query.results.json.data.closing_price)
$('#price').html(price);
});
}
getprice();
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
price: <span id="price">...</span>
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<script>
function getprice(){
$.getJSON("https://api.bithumb.com/public/ticker?Callback=?", function(data) {
var price = parseFloat(data['data']['closing_price'])
$('#price').html( price);
});
}
https://poloniex.com/public?command=returnTicker
poloniex 的 url 运行良好。但 bithumb 不是。
如上所说header有错别字,请联系店主。同时,您可以使用 YQL
进行代理请求function getprice() {
$.getJSON("https://query.yahooapis.com/v1/public/yql?q=select%20*%20FROM%20json%0AWHERE%20url%3D%22https%3A%2F%2Fapi.bithumb.com%2Fpublic%2Fticker%22&format=json&diagnostics=true&callback=", function(data) {
//console.log(data)
var price = parseFloat(data.query.results.json.data.closing_price)
$('#price').html(price);
});
}
getprice();
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
price: <span id="price">...</span>