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

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -