【发布时间】:2018-04-29 14:57:50
【问题描述】:
我从“我的域”向“另一个域”发出 ajax 请求以获取一些信息,我在 Angular 4 应用程序中使用了 XMLHttpRequest 方法,这在除 IE9 之外的所有浏览器 chrome、IE10、IE 11 中都可以正常工作。 问题是 IE9 不支持 XMLHttpRequest 方法,我尝试使用 Typescript 中未定义的 XDomainRequest。 所以我从 lib.d.ts 扩展了 Window 接口,就像在这个链接https://basarat.gitbooks.io/typescript/docs/types/lib.d.ts.html 中指定的那样。 我的问题是如何在我的 AppModule 中包含这个窗口文件并使用 XDomainRequest 发出 ajax 请求。
注意:我的请求域已经启用了 CORS
【问题讨论】:
标签: angular xmlhttprequest cross-domain xdomainrequest typescript-declarations