xmlhttp.open, does not accept subfolders

0

I have a problem. I do the XMLHttp request and everything works fine, however, at the time of opening json it does not load because it is inside a folder, I try as follows ("GET", "date / data.json", true) do not open. If you use the file outside the folder it works "GET", "data.json", true).

I wonder if there is any way to load the file into the folder?

window.onload = function(){
    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = function(){
        if(this.readyState === 4 && this.status === 200){
            var poke = JSON.parse(this.responseText);
            Element.prototype.appendAfter = function (element) {
                element.parentNode.insertBefore(this, element.nextSibling);
            }, false;
            var NewElement = document.createElement('tr');
            NewElement.innerHTML = '<td>'+poke[i].id+'</td><td>'+poke[i].name+'</td><td><img src="'+poke[i].picture+'"/></td>';
            NewElement.appendAfter(document.getElementsByClassName('head-table'));
            NewElement.innerHTML = '<td>ID</td><td>Name</td><td>Picture</td>';
            NewElement.appendAfter(document.getElementById('ref'));
            for(i=0;i<poke.length;i++){
                var NewElement = document.createElement('tr');
                NewElement.innerHTML = '<td>'+poke[i].id+'</td><td>'+poke[i].name+'</td><td><img src="'+poke[i].picture+'"/></td>';
                NewElement.appendAfter(document.getElementById('ref'));
            }
        }
    };
    xmlhttp.open("GET", "data/dados.json", true);
    xmlhttp.send();
};
    
asked by anonymous 15.08.2018 / 17:07

0 answers