admin管理员组

文章数量:1317909

have some troubles! For my requests i'm using Fetch API!

Submit form don't work in IE, because of "SCRIPT5009: 'fetch' is undefined"!

Example how it's looks like:

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)

Same time in Chrome and FF it's works fine! I'm already trying to find some solutions surfing Google, but it was unhelpful!

I was tried to installing "isomorphic-fetch" and "es6-promise" in npm, and tried to import it in my .js file, but it was unsuccessful as well, console shows me this: "Uncaught SyntaxError: Unexpected token import"! Btw, required() function don't work as well! So I'm totally don't now what to do, how to use these polyfill thing and all of that!

If some ones have an idea, thanks in advance! BR!

have some troubles! For my requests i'm using Fetch API!

Submit form don't work in IE, because of "SCRIPT5009: 'fetch' is undefined"!

Example how it's looks like:

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)

Same time in Chrome and FF it's works fine! I'm already trying to find some solutions surfing Google, but it was unhelpful!

I was tried to installing "isomorphic-fetch" and "es6-promise" in npm, and tried to import it in my .js file, but it was unsuccessful as well, console shows me this: "Uncaught SyntaxError: Unexpected token import"! Btw, required() function don't work as well! So I'm totally don't now what to do, how to use these polyfill thing and all of that!

If some ones have an idea, thanks in advance! BR!

Share Improve this question edited Mar 16, 2022 at 9:38 VLAZ 29.1k9 gold badges63 silver badges84 bronze badges asked May 29, 2017 at 12:03 Vadziec PoplavskyVadziec Poplavsky 7691 gold badge7 silver badges12 bronze badges 2
  • 1 It seems like fetch is not supported on IE. developer.mozilla/en/docs/Web/API/Fetch_API – Halcyon Commented May 29, 2017 at 12:04
  • Yup, as I under stand its about native Fetch! But what about packages from npm like "isomorfic-fetch" or "fetch-wg", those are pofylfill! But its now work for me, but works for others! Magic! – Vadziec Poplavsky Commented May 29, 2017 at 12:09
Add a ment  | 

1 Answer 1

Reset to default 8

You can use https://github./github/fetch instead.

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

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

If you need Promise polyfill you can use http://bluebirdjs./docs/install.html

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

Load Bluebird before fetch:

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

本文标签: javascriptSCRIPT5009 39fetch39 is undefinedStack Overflow