My previous questions related to this Read single data in csv data downloaded from url
Code that I refer from here https://gist.github.com/henrik/265014
Sorry if I ask again, but the last answer I got didn't work as it should be in Windows Gadget environment.
I try to use this code in order to get csv data into my variable but all I get is NaN all over.
function getRate(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) {
//var name = data.query.results.row.name;
var rate = parseFloat(data.query.results.row.rate, 10);
console.log("Exchange rate is " + rate);
console.log(rate);
}
getRate("EUR", "USD");
From the url in getRate function, here's the output
{"query":{"count":1,"created":"2015-05-06T04:21:02Z","lang":"en-US","results":{"row":{"rate":"1.1226","name":"EUR/USD"}}}}
I did get the value I want to parseExchangeRate function which is rate but I couldn't parse the value to other variable (abc in this case).
var abc = getRate("EUR", "USD");
console.log(abc);
What I'm supposed to do in order to get the value to the variable? Thanks in advance.