Problems with jQuery getJSON using local files in Chrome

前端 未结 7 1507
情书的邮戳
情书的邮戳 2020-11-22 16:21

I have a very simple test page that uses XHR requests with jQuery\'s $.getJSON and $.ajax methods. The same page works in some situations and not in others. Specificially,

7条回答
  •  粉色の甜心
    2020-11-22 16:50

    This code worked fine with sheet.jsonlocally with browser-sync as the local server. -But when on my remote server I got a 404 for the sheet.json file using Chrome. It worked fine in Safari and Firefox. -Changed the name sheet.json to sheet.JSON. Then it worked on the remote server. Anyone else have this experience?

    getthejason = function(){
    var dataurl = 'data/sheet.JSON';
    var xhr = new XMLHttpRequest();
    xhr.open('GET', dataurl, true);
    xhr.responseType = 'text';
    xhr.send();
    console.log('getthejason!');
    
    xhr.onload = function() {
    .....
    }
    

提交回复
热议问题