我正在使用 jQuery 表单上传文件,但无法从控制器返回任何消息。我在下面做吗?
$(function() {
$('#fileUploadForm').ajaxForm({
type: "POST",
dataType: "json",
beforeSubmit: ShowRequest,
success: SubmitSuccesful,
error: AjaxError
});
});
function ShowRequest(formData, jqForm, options) {
var queryString = $.param(formData);
return true;
}
function AjaxError() {
$("#msgs").html("A file upload error occured.");
}
function SubmitSuccesful(responseText, statusText) {
$("#fileUploadForm").unblock();
$.growlUI(null, responseText.message);
}
public FileUploadJsonResult AjaxPostTypeUpload(HttpPostedFileBase postedFile)
{
try
{
string mess = string.Empty;
mess = "success";
return new FileUploadJsonResult { Data = new { message = mess }};
}
catch { throw; }
}