Why does jQuery throw an error when I request external resources using an Appcache Manifest?

后端 未结 2 525
情歌与酒
情歌与酒 2020-12-21 16:55

I have an application that uses a .appcache manifest. Everything works as expected, resources get cached:

CACHE MANIFEST

CACHE:
css/images/ajax-loader.gif
[         


        
相关标签:
2条回答
  • 2020-12-21 17:20

    As I mentioned in my comment, the problem was not (only) jQuery, but also CORS resp. Google Docs' lack of support of it ("Publish to web" means for download, not for requesting the resource from a different URL, i.e. origin. Apparently Google does not want to add a Header set Access-Control-Allow-Origin "*".

    So what I did instead was follow this helpful guide: https://webapps.stackexchange.com/questions/11864/how-can-i-retrieve-records-from-a-google-spreadsheet-in-json-format and https://developers.google.com/gdata/samples/spreadsheet_sample (The URL is now not CSV but JSONP, it also changed to //spreadsheets.google.com/feeds/list/[...]/[...]/public/values?alt=json-in-script and jQuery automatically adds the callback=xxx when called with:

    $.ajax({
      url : url,
      type : 'GET',
      dataType : 'jsonp',
      success : function (data) {
        for(var i in data.feed.entry) {
          console.log(entry['gsx$' + 'actualColumnHeader'].$t);
        }
      },
      error : function () {
        alert('Failed');
      }
    });
    

    This is not nice or clean by any means (Atom Feed instead of CSV or JSON just to parse it back? Seriously?), but it works for me.

    0 讨论(0)
  • 2020-12-21 17:27

    I've just get it working with tabletop. No more CORS issue.. for now.

    0 讨论(0)
提交回复
热议问题