<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的网址效果很好。但是bithumb不是。
答案 0 :(得分:0)
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>