0

我正在使用 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; }
}
4

1 回答 1

2

尝试只返回一个带有success参数的基本对象:

return new { message = "success" };
于 2013-01-15T10:26:24.343 回答