getValue = ( url, callback) ->
$.getJSON url, (json) ->
value = json.last
callback value
$(window).load ->
btsx_btc = getValue "http://data.bter.com/api/1/ticker/btsx_btc", (data) ->
$('#v_btsx_btc').html data
btc_usd = getValue "http://data.bter.com/api/1/ticker/btc_usd", (data) ->
$('#v_btc_usd').html data
$('#v_btsx_usd').html btsx_btc*btc_usd
I'm pretty new to JavaScript and Coffeescript. I can succesfully retrieve 2 values (btsx_btc & btsc_USD). I want to multiply those 2 variables and show it in the middle one. But its not working, the console is not showing any errors. I presume that the 2 variables are empty somehow. I hope you guys can help
This is the output javascript
(function() {
var getValue;
getValue = function(url, callback) {
return $.getJSON(url, function(json) {
var value;
value = json.last;
return callback(value);
});
};
$(window).load(function() {
var btc_usd, btsx_btc;
btsx_btc = getValue("http://data.bter.com/api/1/ticker/btsx_btc", function(data) {
return $('#v_btsx_btc').html(data);
});
btc_usd = getValue("http://data.bter.com/api/1/ticker/btc_usd", function(data) {
return $('#v_btc_usd').html(data);
});
return $('#v_btsx_usd').html(btsx_btc * btc_usd);
});
}).call(this);