javascript - httpRequest.status code 0 when attempting to retrieve array from local JSON file using AJAX -


i'm trying retrieve array json file named questions.json (that in same folder javascript file). overcome same origin policy, i've allowed xmlhttprequest access local files using chrome --allow-file-access-from-files switch.

i've looked other questions related this, i'm still not sure why request fails. failure related ajax call localhost? doing valid http request? did not overcome same origin policy?

httprequest = new xmlhttprequest();  httprequest.onreadystatechange = function() {     if (httprequest.readystate === xmlhttprequest.done) {         console.log(httprequest.status);         if (httprequest.status === 200) {             var allquestions = httprequest.responsetext          } else {             console.log('there problem request.')         }     } else {         console.log('the request still not ready.')     } }    httprequest.open('get', 'questions.json', true); httprequest.send(null); 

my console shows request still not ready (3 times), xhr has finished loading, httprequest.status 0, there problem request.


Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -