SCRIPT5009:'fetch'是未定义的

有一些麻烦! 对于我的请求,我正在使用Fetch API!

提交表单在IE中不工作,因为“SCRIPT5009:'取'未定义”!

示例如何:

fetch("url", { method: "POST", body: JSON.stringify(data), headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' } }).then(function (response) { return response.json().then(function (data) 

同时在Chrome和FF,它的工作正常! 我已经试图find一些冲浪谷歌的解决scheme,但这是无益的!

我尝试在npm中安装“isomorphic-fetch”和“es6-promise”,并试图将其导入到我的.js文件中,但也不成功,控制台显示了我这样的内容:“Uncaught SyntaxError:Unexpected token import” ! 顺便说一句,必需()函数不工作以及! 所以我完全不用做什么,如何使用这些polyfill的东西,所有这一切!

如果有人有一个想法,提前致谢! BR!

您可以使用https://github.com/github/fetch代替。

CDN: https : //cdnjs.com/libraries/fetch

 <script src="https://cdnjs.cloudflare.com/ajax/libs/fetch/2.0.3/fetch.js"></script> 

如果你需要Promise polyfill,你可以使用http://bluebirdjs.com/docs/install.html

 <script src="//cdn.jsdelivr.net/bluebird/3.5.0/bluebird.min.js"></script> 

读取之前加载Bluebird

 <script src="//cdn.jsdelivr.net/bluebird/3.5.0/bluebird.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/fetch/2.0.3/fetch.js"></script>