1

I have an issue specific to IE8 with the jQuery form plugin.

I am uploading a single file through a multipart/form-data and am using the jQuery plugin to do error handling. Everything works fine in FF but in IE8, the jqHXR object that gets passed in the error handling method is empty (status = 0, text = null, etc. instead of status = 500, text = "Some error message"). Here is some of the code I am using:

HTML Form:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<form name=\"myForm\" id=\"myForm\" action=\"uploadServlet\" method=\"POST\" enctype=\"multipart/form-data\">");
<input type=\"file\" id=\"browseBox\" name=\"file1\"/>
<input type=\"submit\" id=\"uploadButton\"/>
</form>

jQuery:

$("#myForm").submit(upload);
$("#myForm").ajaxForm();

function upload() {
    var options = {
    async: false,
    success: uploadSuccessful,
    error: uploadError
}

    $("#myForm").ajaxSubmit(options);
    return false;
}

function uploadSuccessful(data) {
    alert(data);
}

function uploadError(jqXHR, textStatus, err) {
    alert(jqXHR.responseText);
}

Like I mentioned jqXHR is empty in IE8, but not so in FF. The servlet responds with plain text that I display to the user. Any ideas why IE8 specifically fails at getting the response from my servlet ?

Zerberbuth
  • 11
  • 1
  • 3
  • I should mention I am using jquery 1.7.2 with the form plugin version 3.09 – Zerberbuth Jun 27 '12 at 12:37
  • Have you tried JSFiddle! It paints a much brighter picture in seeing the post and response? Obviously you cannot track the post through the developer console, so thats where JSFiddle will come in handy. Post the results and maybe I can help you. – TYRONEMICHAEL Jun 27 '12 at 14:55
  • Checked a bit more in depth into the plugin itself, and I'm hitting an exception where IE8 is denying access to the iframe containing the response I'm trying to read from. I guess i'll have to play with some settings to make this work. – Zerberbuth Jun 27 '12 at 18:26

2 Answers2

1

It happened to me too, and when i ran Fiddler i found out that using ff/ie9/chrome/etc the request is being sent with POST, but with ie8 it is with GET - which returns a 404 error from server (in my case).. my solution was to add method=post in the form, but i see that u wrote it already. Try to compare the requests from ff and ie8 in fiddler and search for difference.

Ofershap
  • 687
  • 2
  • 7
  • 22
1

IE8 send a file form as a GET request, when you use JqueryForms... You must set

type: "post"

in your jquery forms settings.

czjvic
  • 123
  • 10