[英]AJAX Cross-Domain problem
I have following problem. 我有以下问题。 My webapp is running at
我的webapp正在运行
http://webapp.mysite.com/browser/
And I want to make a request to 我想提出要求
http://mysite.com/request?....
If I make a standart ajax call with the second url I get an error message , domain (same-origin) policy error. 如果我使用第二个url进行标准的ajax调用,我会收到一条错误消息,即域(同源)策略错误。
[object Object]-error-[Exception...
"Component returned failure code: 0x80004005
(NS_ERROR_FAILURE) [nsIXMLHttpRequest.send]"
nsresult: "0x80004005 (NS_ERROR_FAILURE)"
location: "JS frame :: ..../scripts/jquery/js/jquery-1.4.4.min.js ::
anonymous :: line 16" data: no]
Now I tried this ajax php proxy to solve my problem. 现在我尝试了这个ajax php代理来解决我的问题。 But the scripts returns no content.
但脚本不返回任何内容。
var app = 'http://www.mysite.com/rest.php?request=credits';
var proxy = 'proxy.php?proxy_url=' + app;
$.ajax({
url: proxy,
cache: false,
async: false,
dataType: 'html'
success: function(html){
alert(html);
},
error: function(){
}
});
Any ideas? 有任何想法吗?
Ah, perhaps this is the problem: 啊,也许这就是问题所在:
http://api.jquery.com/jQuery.ajax/ http://api.jquery.com/jQuery.ajax/
"Cross-domain requests and dataType: "jsonp" requests do not support synchronous operation." “跨域请求和dataType:”jsonp“请求不支持同步操作。”
And you said, you will use cross-domain requests, so you can not set async
to false. 你说,你将使用跨域请求,因此你不能将
async
设置为false。 Please try it with async = true and give feedback. 请尝试使用async = true并提供反馈。
Ah, and do you get an alert message with empty content? 啊,你收到一条空内容的提醒信息吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.