Question

In every other browser the multi upload form works. Only IE doesn't like it. When i try to submit the form IE starts a 302 redirect on the page in the action="" attribute. The redirect is going to the root of my site.

I already tried it with the iframe/textarea but this also doesn't work. I test it on IE7, IE8, IE9.

Was it helpful?

Solution

Read Here .

This problem has been discussed on github.

Then it helps to understand exactly what the plugin is doing. Since IE < 10 does not support ajax file uploads, the plugin simulates the user experience by submitting the original form with the response targeted to a dynamically created iframe. When the iframe loads the server response, the plugin extracts the response and invokes callback handlers.

In the case where the server responds with a header content-type set to "application/json" that trigger's IE's default download behavior. To avoid this, do not set the content-type header to "application/json". Leave it as text/html or text/plain.

In the case where the server has an actual error it will return an error response page with appropriate status codes set in the response header. This presents two problems for the plugin:

  1. It cannot access the response headers
  2. It cannot determine from the response body whether or not the request was successful

A potential solution, if you have control over the error response page, is to add attributes on the body element that the plugin will look for. The plugin will attempt to access "status" and "statusText" attributes on the response's body element. So if your error page includes something like then your error handler will be triggered.

It's just need do little hack for the IE

  1. use text/html or text/plain instead of 'application/json'.
  2. fully control for the error response, add error message in the successful response body, and then extract and handle it.

No JSON response in jQuery form plugin in IE9

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top