跨域AJAX调用后

编程入门 行业动态 更新时间:2024-10-11 07:28:08
本文介绍了跨域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)

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

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: yourdomain

如果你不能改变你正在访问的服务器,则需要使用代理脚本来自于服务器上 - 交替进行调查,如果他们发表了一个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访问控制(如何)
  • W3Org (Implemation详情)
  • MSDN XDR
  • MDN HTTP access control (how)
  • W3Org (Implemation details)
  • MSDN XDR

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

and several links to the right of this questions

更多推荐

跨域AJAX调用后

本文发布于:2023-11-28 12:46:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1642461.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:跨域   AJAX

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!