I'm trying to call to external PHP script using Ajax like this:
我试图使用Ajax调用外部PHP脚本,如下所示:
$(function() {
$.ajax({'url': 'http://stokes.chop.edu/web/zscore/result.php',
'type': 'POST',
'success': function(response, textStatus, XMLHttpRequest) {
alert('[' + response + ']');
},
'error': function(XMLHttpRequest, textStatus, errorThrown) {
alert('Error');
}
});
});
The result is: []
(i.e. success
function is called!), but I see the following error in HTTPFOX plugin for FireFox:
结果是:[](即调用成功函数!),但我在FireFox的HTTPFOX插件中看到以下错误:
Error loading content (NS_ERROR_DOCUMENT_NOT_CACHED)
加载内容时出错(NS_ERROR_DOCUMENT_NOT_CACHED)
What's wrong with my code ?
我的代码出了什么问题?
1 个解决方案
#1
5
You cannot load contents from pages that does not have the same domain name as the one from which the ajax request is called from. This is a well known security feature call the Same Origin Policy.
您无法从与调用ajax请求的域名不同的域中加载内容。这是一个众所周知的安全功能,称为同源策略。
#1
5
You cannot load contents from pages that does not have the same domain name as the one from which the ajax request is called from. This is a well known security feature call the Same Origin Policy.
您无法从与调用ajax请求的域名不同的域中加载内容。这是一个众所周知的安全功能,称为同源策略。