I'm trying to retrieve stock data using Yahoo's Finance API:
$.ajax({
dataType: "json",
url: 'http://download.finance.yahoo.com/d/quotes.csv',
data: 's=RHT+MSFT&f=sb2b3jk&callback=?',
success: function (d) {
console.log(JSON.stringify(d));
},
error: function (d, a, b) {
console.log(JSON.stringify(d));
console.log(JSON.stringify(a));
console.log(JSON.stringify(b));
},
complete: function (d, a, b) {
console.log(JSON.stringify(d));
console.log(JSON.stringify(a));
console.log(JSON.stringify(b));
}
});
The call works and I can see the csv text in the response (using Chrome's developer tools):
Now, my problem is I can't access the text contained in the response.
As you can see in the original script, I've tried capturing the responses in the "success"
, "error"
, and "complete"
callbacks, but the response text is not contained in any of them. Also, only the "error"
and "complete"
callback is raised.
I'd appreciate any insight on this, thanks in advance!
ps. Reason I'm using the CSV query, as opposed to the YQL query is the CSV query is easier to specify fields I need. I've found the YQL query much more cumbersome to use.