0

I have the following code which is doing a javscript post using an XmlHttpRequest:

var request = new XMLHttpRequest();
var postedFile = document.getElementById("file").files[0];
var formElement = document.getElementById("formID");
var form = new FormData(formElement);

form.append('postedFile', postedFile);
request.open("POST", "/Admin/SaveQuestion/", true);
request.send(form);

This code is working in Chrome, Firefox, IE10, IE11 but I cannot seem to get it to work on IE9. Would this have something to do with the posted file or does my issue lie with the XmlHttpRequest?

Jay
  • 3,012
  • 14
  • 48
  • 99

1 Answers1

1

FormData is not supported in IE9. https://developer.mozilla.org/en-US/docs/Web/API/FormData

Wilmer
  • 2,511
  • 1
  • 14
  • 8
  • Thanks Wilmer least I now know where the problem lies, have you had to do workarounds of similar nature for IE9? – Jay Apr 25 '14 at 12:53
  • I had but I ended up using a plugin like plupload. I found this [answer](http://stackoverflow.com/questions/2320069/jquery-ajax-file-upload) however which doesn't use plugins maybe that helps. – Wilmer Apr 25 '14 at 14:22