0

Can someone, please, explain to me, why in the code snippet below I get request.response == null? In my JSON file I have an array with some data, which I want to use further.

After spending a lot of time on finding a problem, I found that there is a problem with link. When I uploaded JSON file into web service and used a link from that, it works fine. But when I use a link to the file in my file system, it doesn't want to work.

let requestURL = "../sliderContent.json";

const request = new XMLHttpRequest();
request.open('GET', requestURL);
request.responseType = 'json';
request.send();
request.onload = () => {
    if (request.readyState === 4 && request.status === 200) {
        let slidesContent = request.response;
        console.log(slidesContent);
        returnSlidesReducer(slidesContent);
    }
};
Ivan Burzakovskyi
  • 693
  • 1
  • 8
  • 25
  • Add the two links please. – Abhi Mar 25 '18 at 03:34
  • Possible duplicate of [AJAX request to local file system not working in Chrome?](https://stackoverflow.com/questions/38344612/ajax-request-to-local-file-system-not-working-in-chrome) – Ben Mar 26 '18 at 03:33

0 Answers0