I have a function with jquery getJSON and i need the return the result value back (to Use it somewhere else)
Here is the code:
function getval(){
jQuery.
You might try using a callback
function:
function getval( callback ){
jQuery.getJSON('http://data.mtgox.com/api/1/BTCUSD/ticker?callback=?', function(data) {
// We can't use .return because return is a JavaScript keyword.
callback(data['return'].avg.value);
});
}
$(function () {
$(document).ready(function() {
getval( function ( value ) { alert( 'Do something with ' + value + ' here!' ) } );
});
});