Error:- XMLhttpRequest Cannot load ? How to handle this error.



XMLHttpRequest cannot load Error
Browser Error



Solution:-
This is common error when you attempt to open load files directly in chrome.
Reason,
Chrome and other browsers have imposed security restrictions for “Cross Origin Requests“, which means that you cannot load the files directly from your local hard-disk to browser hence you required to load the files on some server using some protocol. Eg: http.

There are different ways to resolve this issue:
Approach-1:- Search for the path of your Chrome executable and then, on your cmd, try :

  •  Type “where chrome” into command prompt which will give you “C:PathToChrome.exe”
  • Then type ” C:PathToChrome.exe –allow-file-access-from-files “

Cmd Prompt chrome.exe


Note:-It is better to close all the browser instances before executing the above commands.

Approach-2:- If you have node setup then you can use http-server.
Execute npm install –g http-server and you will be able to access it using http-server C:pathtoapp

Step1:- install node.js 
sudo  npm install –g http-server 

Step2:- Browse to the file location of .html file and execute the below command

http-server

how to run node.js server


Step3:- Access the file using http://127.0.0.1:8080/ in browser

Approach-3:- Mount Apache server and deploy your code to run the app.

Note:-Some IDE’s have default built in web servers like JetBrains, Eclipse

Do follow us for more learning and solutions Fb,G+,Twitter

Learn AngularJs

Leave a Reply

Your email address will not be published. Required fields are marked *