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 ?

4

2 回答 2

1

IE8 将文件表单作为 GET 请求发送,当您使用 JqueryForms... 您必须设置

type: "post"

在您的 jquery 表单设置中。

于 2013-02-28T08:20:12.863 回答
1

它也发生在我身上,当我运行 Fiddler 时,我发现使用 ff/ie9/chrome/etc 时,请求是通过 POST 发送的,但对于 ie8,它是使用 GET - 从服务器返回 404 错误(在我的情况下) ).. 我的解决方案是在表单中添加 method=post,但我看到你已经写过了。尝试比较 fiddler 中来自 ff 和 ie8 的请求并寻找差异。

于 2012-10-18T14:12:39.927 回答