简体   繁体   English

XMLHttpRequest在IE9中不起作用

[英]XMLHttpRequest not working in IE9

I do ajax request from my "mydomain" to "anotherdomain" to get some information, i used XMLHttpRequest method in my Angular 4 application, this works fine in all browsers chrome, IE10, IE 11 except IE9. 我从我的“ mydomain”到“ anotherdomain”执行ajax请求以获取一些信息,我在Angular 4应用程序中使用了XMLHttpRequest方法,该方法在所有浏览器chrome,IE10,IE 11(IE9除外)上都可以正常工作。 The problem is XMLHttpRequest method is not supported by IE9, i tried to use XDomainRequest which is not defined in Typescript. 问题是IE9不支持XMLHttpRequest方法,我尝试使用TypeScript中未定义的XDomainRequest。 So i extended the Window interface from lib.d.ts as like specified in this link https://basarat.gitbooks.io/typescript/docs/types/lib.d.ts.html . 因此,我像下面的链接https://basarat.gitbooks.io/typescript/docs/types/lib.d.ts.html中所指定的那样,从lib.d.ts扩展了Window接口。 My question is how do i include this window file in my AppModule and use XDomainRequest to make ajax request. 我的问题是如何在我的AppModule中包含此窗口文件并使用XDomainRequest发出Ajax请求。

Note: My request domain is already CORS enabled 注意:我的请求域已启用CORS

Angular itself is compatible down to IE9, so I think you can solve your problem by simply using the HttpClient from Angular. Angular本身向下兼容IE9,因此我认为您可以通过使用Angular的HttpClient来解决您的问题。

Edit: 编辑:

An Example from the official documentation: https://angular.io/guide/http 官方文档中的示例: https//angular.io/guide/http

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM