XMLHttpRequest Cannot Load error in AngularJS – User friendly Tech help

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

n

n

n

n

n

n

n

n

Browser Error

n

Solution:-
nThis is common error when you attempt to open load files directly in chrome.
nReason,
nChrome 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.

n

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

n

    n

  •  Type “where chrome” into command prompt which will give you “C:PathToChrome.exe”
  • n

  • Then type ” C:PathToChrome.exe –allow-file-access-from-files “
  • n

nn

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

n

Approach-2:- If you have node setup then you can use http-server.
nExecute npm install –g http-server and you will be able to access it using http-server C:pathtoapp
n
Step1:- install node.js 
nsudo  npm install –g http-server 
n
nStep2:- Browse to the file location of .html file and execute the below command

n

http-server

nn


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

n

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

n

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

n

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

n

Learn AngularJs

Was this article helpful?
YesNo

Similar Posts