Possible Duplicate:
XmlHttpRequest error: Origin null is not allowed by Access-Control-Allow-Origin
I still don't get why this code works fine when loading local server pages (localhost) but display nothing when trying to fetch remote data
$(document).ready(function(){
$.get(
"message.html",
function(data) { $("div").html(data); },
"html"
);
});
and displaying the remote html file gives me no error but no data:
$(document).ready(function(){
$.get(
"http://viralpatel.net/blogs/2009/04/jquery-ajax-tutorial-example-ajax-jquery-development.html",
function(data) { $("div").html(data); },
"html"
);
});
Regards
There is a built-in restriction to prevent cross-domain Ajax requests from the browser. Pretty much all browsers implement this.
There are workarounds such as the article here or using JSONP. But this is a basic restriction put on Ajax requests sent from the browser. If you are using ASP.NET Encosia also had a good tip on doing the proxying using a custom HttpHandler.
See also: Cross Domain Limitations With Ajax - JSON
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With