1

I whant to load remote html page and then parse it. There are bunch of such examples but could anybody explain why I receive this error:

XMLHttpRequest cannot load http://html.comsci.us/examples/blank.html. Origin null is not allowed by Access-Control-Allow-Origin.

when I try to load this html page:

<!DOCTYPE HTML>
<html>
  <head>
  <script type="text/javascript"
     src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
  <script>
      $(document).ready(function(){ 
        $.get('http://html.comsci.us/examples/blank.html', function(data) {
           alert('Load was performed.');
        }); 
      });
    </script>
  </head>
  <body>
  </body>
</html>
2
  • 1
    XMLHttpRequest can't cross domain due to security issues. Commented Jun 20, 2012 at 16:05
  • @semsorock, suggestions for future questions: no need for "thank you notes", up-vote/accept answers instead. Try to format code so there is no horizontal scroll (preferably provide small enough samples so there is no vertical scroll either). Commented Jun 21, 2012 at 5:56

2 Answers 2

0

You need to create a script on your own server that requests that page, and you call that script using your ajax request.

Sign up to request clarification or add additional context in comments.

1 Comment

Some code would be nice
0

The security restriction you are hitting is called "same origin policy" or "cross-domain access".

Ways to work around:

  • make query server side or with client application
  • if both sites agree on access you can use CORS, running code on other site
  • JSONP if other site supports it

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.