[英]Is that possible to call to external PHP script from Ajax?
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: []
(ie success
function is called!), but I see the following error in HTTPFOX plugin for FireFox: 结果是: []
(即调用success
函数!),但是在FireFox的HTTPFOX插件中看到以下错误:
Error loading content (NS_ERROR_DOCUMENT_NOT_CACHED) 加载内容时出错(NS_ERROR_DOCUMENT_NOT_CACHED)
What's wrong with my code ? 我的代码有什么问题?
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. 您不能从与从其调用ajax请求的域名不具有相同域名的页面中加载内容。 This is a well known security feature call the Same Origin Policy. 这是众所周知的安全功能,称为“相同来源策略”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.