Reputation: 11
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>
Upvotes: 1
Views: 6608
Reputation: 100547
The security restriction you are hitting is called "same origin policy" or "cross-domain access".
Ways to work around:
Upvotes: 0
Reputation: 11744
You need to create a script on your own server that requests that page, and you call that script using your ajax request.
Upvotes: 0