Search code examples
javascriptjqueryyahoo-finance

File isn't Downloading


I'm attempting to download a CSV file through Yahoo Finance with this code.

$(function () {
    $(document).ready(function() {
        $.get("http://download.finance.yahoo.com/d/quotes.csv?f=snl1d1t1c1ohg&s=AAPL", function(data) {
            var output = data.split(new RegExp(",|\r")).map(function (element) {
                alert($.trim(element).toLowerCase());
                return $.trim(element).toLowerCase();
            });
        });
    });
});

You can see I put the alert in there (for debugging purposes) but I'm not getting the alert. Is there something wrong with this code? (some of the code was taken from how to create an array by reading text file in javascript)

Here's a jsFiddle for easy edits/help.


Solution

  • This is blocked by same-origin policy.

    Options:

    • find other service that provides access to the data with JSONP or have CORS enabled for the data source.
    • use server side proxy to read data