用ajaxFileUpload时,MVC的Controller层,不能用JSON去返回数据,因为前台会接不到
返回信息不能用json(),而是要转换一下。    
return Content(JsonHelper.Serializer(res));


function singleUpload() {
        if (!$('#singleFile').val()) {
            alert('请选择需要上传的文件!');
            return false;
        }
        var url = '@Url.Action("UplpadMailAttachment")';

        
        $.ajaxFileUpload({
            type: 'POST',
            url: url,
            secureuri: false,
            fileElementId: 'singleFile', //文件选择框的name属性
            dataType: 'json', //服务器返回的格式 xml,script,json,html 
            success: function (data, status) //相当于java中try语句块的用法
            {   
                if (data.IsSuccess) {
                    alert(data.Message);
                    $("#hfVisaAttachmentPath").val(data.Message);
                } else {
                    alert(data.Message);
                }

            },
            error: function (data, status, e) //相当于java中catch语句块的用法
            {
                console.log(data);
                console.log(status);
                console.log(e);
                alert(e);
            }
        });
    }




相关文章:

  • 2021-12-20
  • 2022-01-10
  • 2022-12-23
  • 2022-01-18
  • 2022-12-23
  • 2021-10-23
  • 2022-12-23
  • 2021-11-08
猜你喜欢
  • 2022-12-23
  • 2021-06-09
  • 2021-12-08
  • 2021-11-22
  • 2021-10-09
  • 2021-10-26
相关资源
相似解决方案