Cross-Site XmlHttp (XDomainRequest)

ぃ、小莉子 提交于 2019-12-13 17:11:50

问题


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.

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".

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

Edit: 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.


回答1:


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.




回答2:


Yes, no matter if requests are on same server, you cannot do cross-domain XmlHttp requests. I don't know what are you trying to achieve but you can't do that with your listed tags.

You should consider some programming.

You can make a little proxy page in any programming you want and make those XmlHttp requests threw that proxy.



来源:https://stackoverflow.com/questions/7143847/cross-site-xmlhttp-xdomainrequest

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!