Please consider this javascript:
$.ajax({
url:'http://ichart.finance.yahoo.com/table.csv?s=GS&a=00&b=1&c=2010&d=08&e=3&f=2012&g=d&ignore=.csv',
type:'get',
dataType:'jsonp',
success:function(data){
alert(data);
}
})
The URL returns a .csv file, but I am specifying the jsonp
data type because this is a cross-domain ajax request. Without that parameter I get the "origin is not allowed" error.
Since I specify the jsonp
data type, the ajax function throws an error because the .csv file is not JSON format. But in the dev console I can see that the browser DOES receive a coherent .csv file. So I know I am successfully receiving the CSV file. I think it should be possible, but I am not sure how to correctly receive this csv file to my ajax function??
Of course if I could make this URL return a correctly formatted JSON string that would be the best, but I am not sure I can do that.
Here is a fiddle where you can try it, you will have to open up the dev console to see that error: http://jsfiddle.net/92uJ4/3/
Any help is greatly appreciated.
Tim