jQuery ajax working on local file but not working from a remote url?
I am currently trying to get data from a remote url using jQuery ajax calls.
I am just using a basic jquery function to do this. When using a local file the functions works correctly but it does not get a remote file.
开发者_JAVA技巧I'm using the local files using Mamp on my local pc.
$.ajax({
url: "URL",
success: function(data) {
$('#notification').html(data);
}
});
Any ideas why this may not be work would be a great help?
Thanks, Kane
Sounds like Same origin policy. You might need to use JSONP.
when you say 'remote file' do you mean like from another domain? coz browsers typically don't allow that.
See this JQuery external Ajax call not working in IE
Cross domain ajax request is not allowed typically. You can take a look to these answers:
jQuery AJAX cross domain
problem with cross-domain ajax calls
精彩评论