How can I load a cross-domain HTML page using jQuery AJAX?
Suppose I want to get a page outside my domain using jQuery AJAX:
$.get('http://www.domain.com/mypage.html', function(data) {
alert(data);
});
I will probably get this error message:
XMLHttpRequest cannot load http://www.domain.com/path/filename . The origin of null is not allowed by Access-Control-Allow-Origin.
we cannot load a cross-domain page using AJAX due to policies of the same origin .
I could try using "jsonp" to get around this limitation:
$.ajax({
type: "GET",
url: url,
dataType: "jsonp",
success: function(data){
console.log(data);
}
});
But what if "jsonp" is not supported on this site? this can be a problem.
, HTML?