Hello,
I have created a samll sample which you can use for testing and should help you in achieving what you are trying.
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript">
$(document).ready(function() {
getval(showAlert);
});
function getval( callback ) {
$.getJSON('http://data.mtgox.com/api/1/BTCUSD/ticker')
.done(function(data) {
callback(data.return.avg.value);
});
}
function showAlert(val) {
alert( 'Do something with ' + val + ' here!' );
}
</script>
</head>
<body>
</body>
</html>
Regards