本地主机::跨域AJAX [英] localhost :: cross domain ajax

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

问题描述

有没有办法告诉你的本地主机,它可以做跨域Ajax调用?

Is there any way to tell your localhost that it can do cross domain ajax calls?

我需要为我的测试。

如果这是我使用谷歌的Chrome浏览器特定的问题。

If it is a browser specific issue i am using google chrome.

干杯。

推荐答案

没有,这是绝对不可能的。如果它可以被用户禁用那么这将是对任何人恶意或可疑意图的主要对象,而容易产生的任何其他软件开发。这是很难做出足够安全的软件,没有画上更具吸引力的目标。

No, it's absolutely not possible. If it could be disabled by the user then it would be the main target for anyone with nefarious or dubious intent, and as prone as any other software to exploitation. It's difficult enough making secure software, without painting on even more attractive targets.

要实现跨域Ajax是通过服务器端脚本发送请求的唯一方法。

The only way to implement cross-domain Ajax is to route requests via a server-side script.

值得一提的是,也许,希望对您一线希望:在的交叉窗口消息与HTML 5 postMessage的

It's worth mentioning that there is, perhaps, a glimmer of hope for you: in the form of cross-window messaging with HTML 5 postMessage

这也许是值得拥有的一些相关读你的(虽然我不知道他们是重复的)问题:

It's probably worth your having a read of some related (though I'm not sure they're duplicate) questions:

  • Why the cross-domain Ajax is a security concern?
  • Firefox Cross Domain Request


编辑回应发表评论:


Edited in response to comment:

所以,你的意思是有一个脚本,需要的参数,可以将它们添加到该请求,将其发送出去,然后再进行回声响应对象?

So you mean have a script that takes the params, adds them to the request, sends it out, and then echos out the response object?

从本质上讲是肯定的。在图片格式:

Essentially yes. In picture format:

client  |--------------> | server side |----------------------->  | remote domain
browser | <----ajax------|   script    | <------------------------|--/


编辑补充说,这是可能的排序现在,利用跨域资源共享(的 CORS );其中从一个域脚本发送起源HTTP头,说明该页面的URL,服务器可以响应(如果配置的话)符合任何一个错误(如果CORS被禁用,或不支持),或与任何请求的数据。


Edited to add that this is now sort of possible, using Cross-Origin Resource Sharing (CORS); in which a script from one domain sends an Origin HTTP header stating the URL of the page, and the server can respond (if configured to do so) with either an error (if CORS is disabled, or unsupported) or with any requested data.

参考文献:

  • CORS compatibility.
  • Cross-Origin Resource Sharing, at the W3.org.
  • Enable Cross-Origin Resource Sharing.

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

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