AJAX跨域问题 [英] AJAX Cross-Domain problem

查看:80
本文介绍了AJAX跨域问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下问题。我的web应用程序是在

I have following problem. My webapp is running at

http://webapp.mysite.com/browser/

和我想提出一个要求,以

And I want to make a request to

http://mysite.com/request?....

如果我做的第二个URL,我得到一个错误信息的,域(同源)的政策错误非标准AJAX调用。

If I make a standart ajax call with the second url I get an error message , domain (same-origin) policy error.

 [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]

现在我试着这阿贾克斯PHP代理解决我的问题。但剧本不返回任何内容。

Now I tried this ajax php proxy to solve my problem. 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(){

    }
});

任何想法?

推荐答案

嗯,也许这就是问题所在:

Ah, perhaps this is the problem:

http://api.jquery.com/jQuery.ajax/

跨域请求和数据类型:请求不支持同步操作JSONP

"Cross-domain requests and dataType: "jsonp" requests do not support synchronous operation."

和你说,你会使用跨域请求,所以你不能设置异步为false。请异步试试吧= TRUE并提出反馈意见。

And you said, you will use cross-domain requests, so you can not set async to false. Please try it with async = true and give feedback.

嗯,和你得到一个警告消息,内容为空?

Ah, and do you get an alert message with empty content?

这篇关于AJAX跨域问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆