0

I'm trying to load some scripts from within my app.js file that contains all the javascript logic for my application, but am getting following error in chrome console:

XMLHttpRequest cannot load file:///... Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.

$.getScript('lib/fastclick.js', function () {
     /* ... */
});

this is being tested locally, haven't uploaded it to my server yet, maybe the issue will not appear there, however I would like to know the cause and perhaps the fix to be able and continue working locally.

Ilja
  • 44,142
  • 92
  • 275
  • 498

1 Answers1

2

this is being tested locally, haven't uploaded it to my server yet, maybe the issue will not appear there,

Correct.

Your local test environment should include an HTTP server. There are many differences between a webpage environment loaded over HTTP and one loaded over FILE.

however I would like to know the cause

Web pages running on your hard disk are not allowed to access other files on your hard disk with JS. Imagine what would happen if that wasn't the case and you opened an HTML document attached to an email sent by someone malicious.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335