I have a problem with returning value of callback function. I have a main function with two functions.
The problem is that the main function returns "undefined". It is important for me to get the value from main function.
var rate = 0;
function main(sum, from, to) {
var script = document.createElement('script');
script.setAttribute('src', "http://query.yahooapis.com/v1/public/yql?q=select%20rate%2Cname%20from%20csv%20where%20url%3D'http%3A%2F%2Fdownload.finance.yahoo.com%2Fd%2Fquotes%3Fs%3D" + from + to + "%253DX%26f%3Dl1n'%20and%20columns%3D'rate%2Cname'&format=json&callback=parseExchangeRate");
document.body.appendChild(script);
function parseExchangeRate(data) {
rate = parseFloat(data.query.results.row.rate, 10);
}
return rate * sum;
}