-1

I'm trying to get some information to my website from an other URL but I have this error when my page tries to load the content.

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

I'm using this JavaScript to get the information.

<script type="text/javascript">
   $(document).ready(function() {
      $("#div").load('urltarget class_contentinfo');
    });
 </script>
RafH
  • 4,504
  • 2
  • 23
  • 23
  • um, are those variables that you are treating as a string? – epascarello Feb 20 '14 at 20:41
  • If you make a new question, and type the exact title of your question (which you just did), you can see a lot of suggestions. This is because this questions has been asked dozens of times before. – GolezTrol Feb 20 '14 at 20:47
  • possible duplicate of [XMLHttpRequest cannot load an URL with jQuery](http://stackoverflow.com/questions/3828982/xmlhttprequest-cannot-load-an-url-with-jquery) – GolezTrol Feb 20 '14 at 20:49

1 Answers1

0

you can't just load a page from another url that isn't yours. The problem is, as you already pointed out, the Access-Control-Allow-Origin header.

This means the page you are trying to load data from didn't whitelist your page as a valid source.

Let's consider you are foo.com and you want to load data from bar.com through a XMLHttpRequest, bar.com has to send either Access-Control-Allow-Origin: foo.com or Access-Control-Allow-Origin: *

More information on this topic can be found here: http://en.wikipedia.org/wiki/Cross-origin_resource_sharing

redshark1802
  • 894
  • 2
  • 12
  • 22