我在 asp.net mvc3 中使用这个插件通过 Ajax 上传文件。 http://malsup.com/jquery/form/#ajaxSubmit 但它在 IE7 中不起作用。
$("#Controls").submit(function () {
var options = {
url: "/Education/upDoc",
datatype: "json",
success: showResponse
};
$(this).ajaxSubmit(options);
});
function showResponse(responseText, statusText, xhr, $form) {
alert("sr");
alert("Sr " + responseText.success);
if (responseText.success == true) {
//some code
}
}
<form action='' id='Controls' method='post' enctype='multipart/form-data'>
<table>
<tr>
<td>File Type</td>
<td><span class='leftten'></span></td>
<td>
@*<select id='documentType' name='documentType'>
</select> *@
@Html.DropDownList("documentType", doctypelist, new { @id = "documentType" })
</td>
<td><img src='../../img/AlertSign.jpg' class='errImgDoc' data-style-tooltip='tooltip-shiny-red' title='' id='errFileType' height='18px' width='20px'/></td>
<td><span class='leftfortytwo'></span></td>
<td><input type='file' id='file' name='file' /></td>
<td><img src='../../img/AlertSign.jpg' class='errImgDoc' data-style-tooltip='tooltip-shiny-red' title='' id='errFile' height='18px' width='20px' /></td>
<td><span class='leftfortytwo'></span></td>
<td>Name</td>
<td><span class='leftten'></span></td>
<td><input type='text' id='description' name='description' /></td>
</tr>
</table>
<br />
<div align='right'>
<table><tr>
<td><input type='button' id='eduUploadCancel' class='Cancel' onmouseover='CancelHover(this)' onmouseout='CancelMouseOut(this)' onclick='Cancel(this)' /></td><td><span class='leftten'></span></td><td><input type='submit' id='eduUploadSave' class='Save' onmouseover='SaveHover(this)' onmouseout='SaveMouseOut(this)' /></td></tr></table>
</div>
</form>
在这里,showResponse()
永远不会用 IE7 调用。在 Chrome 和 Firefox 上运行良好。请帮助!