1

我正在使用jQuery表单插件上传图像在我的MVC项目。ajax提交不工作在IE jQuery表格插件

由于某些原因,IE中的代码不再有效(以前工作过): 我可以告诉提交成功,图像上传成功,并在数据库中重新编码,但响应似乎在IE中被破坏。

function showResponse(responseText, statusText, xhr, $form) { 
      $("#loading").hide(); 
      AddImage(responseText.ImageId); 
      buildArray(); 
     } 

我在Firefox,Chrome,Safari上测试过,但所有的工作都很好,但是当我在IE中使用它。

我得到错误:

Message: 'ImageId' is null or not an object

任何人以前曾经有过任何类似的问题?

在此先感谢!

+0

你可能想看看这里我的答案 [http://stackoverflow.com/questions/15425231/ajaxsubmit-and-internet-explorer-issue/20022629#20022629][1] [1]:http://stackoverflow.com/questions/15425231/ajaxsubmit-and-internet-explorer-issue/20022629#20022629 – Vlad 2013-11-16 19:19:43

回答

1

那么通过将内容类型从“text/plain”更改为“text/html”就可以解决问题,就是这样。

OMFG,Internet Explore!

代码我已经改变了:

return Json(newImage, "text/html", Encoding.Unicode, JsonRequestBehavior.AllowGet); 

希望能帮助别人也是如此。

0

由于有关文件上传的文档中说:

需要注意的是,即使当一个数据类型选项设置为“脚本”是很重要的,并且服务器实际上是有一些JavaScript响应一个多表单提交,响应的内容类型标题应强制为text/html,否则Internet Explorer将提示用户下载“文件”。

我不知道它在以前工作过,但文档很清楚这个问题。