跨域AJAX调用后 [英] cross-domain AJAX post call

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

问题描述

我已经做出POST调用(带参数)到位于另一台服务器上的ASP形式。

I've to make a POST call(with parameter) to an asp form which is located on another server.

有关的发展,我这样做是在同一台服务器上,它完美的作品,但现在我的另一台服务器,而是收到200状态上测试它,我收到一个0状态。

For development, I did this on the same server, and it works perfectly, but now I'm testing it on another server, and instead of receiving a 200 status, I receive a 0 status.

我想这是因为它是一个跨域AJAX调用,这是它唯一改变的。那么,如何可以做这样的判断?是否有任何文件,我可以把服务器/客户端上,让这个呼叫(如Flash,...)?

I think it's because it's a cross-domain AJAX call, it's the only thing which changed. So how can I make this call? Is there any file I can put on the server/client to allow this call(like flash, ...)?

感谢您!

推荐答案

是的,假设你可以连接服务器更改为

Yes, assuming you can change the server you connect to

您可以实现跨地资源共享(CORS)

您需要服务器返回访问控制 - 允许 - 产地:* 如果要允许所有域的访问,否则返回访问 - 控制 - 允许原产地: http://yourdomain.com

You need the server to return Access-Control-Allow-Origin: * if you want to allow all domains to access, otherwise return Access-Control-Allow-Origin: http://yourdomain.com

如果你不能改变你正在访问的服务器,则需要使用代理脚本来自于服务器上 - 交替进行调查,如果他们发表了一个API返回例如JSONP

If you cannot change the server you are accessing, you need to use a proxy on the server your script comes from - alternatively investigate if they have published an API to return for example JSONP

更多细节在这里

  • MDN HTTP access control (how)
  • W3Org (Implemation details)
  • MSDN XDR

和几个环节对这一问题的正确

and several links to the right of this questions

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

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