首页 > 代码库 > TypeError: 'append' called on an object that does not implement interface FormData 解决方法

TypeError: 'append' called on an object that does not implement interface FormData 解决方法

  使用ajax提交form表单时,$("formId").serialize()不能提交type="file"类型的input,这个时候可以选择使用FormData,使用方法如下

var dataForm = new FormData(document.getElementById("queryForm"));
                $.ajax({

                    processData: false,//这个必须有,不然会报错
                    contentType: false,//这个必须有,不然会报错
                    type: "POST",
                    url:"/trail/shopdeepupload",
                    data:dataForm,
                    async: false,
                    dataType:"json" ,
                    success: function(data) {

                        if(datahttp://www.mamicode.com/=="false"){
                            showTipPanel("上传失败,请重试!");
                        }
                        if(datahttp://www.mamicode.com/=="true"){
                            showTipPanel("上传成功!");
                            setInterval(retFun(),1000);
                        }
                    }
                });

 

 

TypeError: 'append' called on an object that does not implement interface FormData 解决方法