jQuery ajax working on local file but not working

2019-05-29 08:56发布

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.

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

3条回答
虎瘦雄心在
2楼-- · 2019-05-29 09:43

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

查看更多
Ridiculous、
3楼-- · 2019-05-29 09:45

Sounds like Same origin policy. You might need to use JSONP.

查看更多
ら.Afraid
4楼-- · 2019-05-29 09:47

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

查看更多
登录 后发表回答