-5
var formd = new FormData(form);
    formd.forEach(function(value, key){
        data[key] = value;
});

How can I make this forEach function to work in Edge by replacing it with for loop?

TylerH
  • 20,799
  • 66
  • 75
  • 101
Laken-JS
  • 11
  • 1
  • 1
    Are you sure this works in chrome? – Ankit Agarwal Jul 27 '18 at 08:27
  • please add `FormData`. it looks like you return an instance of the function which is not an array. this is not only a problem of IE, but of language specification, which requires an array. – Nina Scholz Jul 27 '18 at 08:27
  • 1
    @Nina Scholz: https://developer.mozilla.org/de/docs/Web/API/FormData – Lain Jul 27 '18 at 08:33
  • @Lain, thank you, didn't know. `FormData` returns an instance, as thought without `forEach` method. – Nina Scholz Jul 27 '18 at 08:39
  • 1
    @Nina Scholz: Yes, depends on the browser. In Chrome and Firefox it does, in Edge it does not. – Lain Jul 27 '18 at 08:44
  • @Ankit Agarwal It doesn't work only in Edge and IE – Laken-JS Jul 27 '18 at 08:59
  • @Laken-JS: As you can see in my link Edge aswell as IE do not have iteration support with `FormData`. So you are right - it does and will not work like this. Read thise one: https://stackoverflow.com/questions/37938955/iterating-through-formdata-in-ie – Lain Jul 27 '18 at 09:03

1 Answers1

1

Would mark it as duplicate if I could (maybe someone else can). IE11 and Edge do not support iteration in FormData. https://developer.mozilla.org/de/docs/Web/API/FormData

One needs a polyfill to correct it. Here is a way to fix it: Iterating through FormData in IE

Lain
  • 3,657
  • 1
  • 20
  • 27