本文介绍了跨站点XMLHTTP(XDomainRequest)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在写一个基于Web的工具,我的公司,它正在流失本地Intranet和在IE8上运行。我相信,因为该公司的电脑都是在国有企业,没有人有控制权,除非IT部门的浏览器设置,他们将不会做任何改变,至少在我们需要它的期限。

I'm writing a web-based tool for my company and it is running off the local intranet and running in IE8. I believe since the company computers are in a SOE, nobody has control over the browser settings except the IT department and they will be unlikely to make any changes, at least not in the timeframe we need it.

我有一个XMLHTTP请求,这是在受信任的站点(也对本地Intranet)的URL,但是当我发送请求,我得到一个异常:访问被拒绝,当我捕捉异常并输出到我的网页,我得到类型错误:访问被拒绝。

I have an XmlHTTP request to a URL which is in "Trusted Sites" (also on the local intranet), but when I send the request, I get an exception: "Access is denied", and when I catch the exception and output it to my page, I get "TypeError: Access is denied".

有没有什么办法可以让IE8完成这个AJAX请求?

Is there any way I can get IE8 to complete this AJAX request?

编辑:经进一步研究,事实证明,这个问题可能没有什么关系受信任的站点/本地Intranet毕竟。 Apparenly你不能做跨域XMLHTTP请求。我的系统是通过一个IP地址进行访问,而我的AJAX脚本的目标网站(还是本地)域,它解析为一个不同的IP地址。不幸的是我已经试着写一个PHP脚本将获取页面从服务器端,但它也拒绝无需用户名/密码进行连接。

Upon further researching, it turns out that the problem may not have anything to do with trusted sites/local intranet after all. Apparenly you can't do cross-domain XmlHttp requests. My system is accessed by an IP address, whereas the target site of my AJAX script is (still local) a domain, which resolves to a different IP address. Unfortunately I've already tried writing a PHP script which will get the page from the server-end, however it also refuses to connect without a username/password.

目前这个阶段,我愿意就如何解决这个问题的任何哈克建议。如果我能得到这个功能工作,这将节省手动输入数据我们天。

At this stage I'm open to any hacky suggestions on how to get around this. If I can get this function to work, it will save us days of manually inputting data.

推荐答案

由于IE8不支持的你要么做代理或让与的或得到下相同的IP的一切。

Since IE8 does not support CORS you either have to do a proxy or make the request with JSONP or get everything under the same IP.

这篇关于跨站点XMLHTTP(XDomainRequest)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 13:11