0

So I am using extJs and followed tutorials. But I can't figure something out. When I'm using my extJs library on localhost I get the error described in the title. The full error is something like this:

HttpRequest cannot load ********** No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.

My html code is the following:

<html>
<head>
    <link rel="stylesheet" type="text/css" href="http://localhost/IWL/ext-5.0.1/build/packages/ext-theme-neptune/build/resources/ext-theme-neptune-all.css">
   <script type="text/javascript" src="http://localhost/IWL/ext-5.0.1/ext-all.js"></script> 
   <script type="text/javascript" src="http://localhost/IWL/ext-5.0.1/build/packages/ext-theme-neptune/build/ext-theme-neptune.js"></script>
   <script src = 'main.js'></script></head>
</html>

Do I have to change something in xampp? In my html code? in js?

István
  • 5,057
  • 10
  • 38
  • 67
user3464409
  • 69
  • 1
  • 3
  • 12
  • 1
    If you can, host and request files via `http://` rather than using `file://`. You can also [start Chrome with an additional option enabled](http://stackoverflow.com/questions/4208530/xmlhttprequest-origin-null-is-not-allowed-access-control-allow-origin-for-file). The error is because Ajax requests are [validated by the current origin](https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy) and `file://` isn't considered as having an origin to validate ("*Origin **'null'** is [...]*"). – Jonathan Lonowski Sep 08 '14 at 20:35
  • Can you specify this? In my code there is no file:// only http as sources for the scripts! – user3464409 Sep 09 '14 at 05:32
  • This page/html should be requested with `http://` as well. The origin is based on the current address (`window.location`). And, the protocol used for the page will be reused for the relative `main.js`. – Jonathan Lonowski Sep 09 '14 at 13:36

0 Answers0