Search code examples
javascriptangularjsinternet-explorer-9cross-domaingoogle-docs-api

Cross domain google doc request for IE9


I am trying to retrieve data from a google doc spreadsheet using Angular's $http. Everything generally works fine but there is a cross domain issue with IE9 and I get an 'Access is denied' Error.

Here is the code for my angular service (obviously switching the docID in the google doc url):

app.factory('Messages', function ($http, $q) {

    var googleDoc = 'https://spreadsheets.google.com/feeds/list/*docID*/od6/public/values?alt=json';

    var Messages = {
        all: function() {

            var defered = $q.defer();
            var messages = [];

            $http.get(googleDoc).success(function(data) {

                for (var i = 0; i < data.feed.entry.length; i++) {
                    messages[i] = {
                        'name' : data.feed.entry[i].gsx$name.$t
                    }
                };
                defered.resolve(messages);
            });
            return defered.promise;
        }
    };
    return Messages;
});

I've tried various suggested techniques to get this to work on IE9, but no success so far. Any ideas greatly appreciated.


Solution

  • In answer to my own question, the only solution I can find is routing the request via some sort of proxy.

    This php script seems to work well http://benalman.com/projects/php-simple-proxy/