form: function (url, paras, files, success) {//上传的文件类型是MultipartFile[]//如果把需要的参数直接传入,则会请求错误//设置请求参数的数据类型 var urlStr = UrlParas(url, paras).url; console.log(urlStr) var formData = new FormData(); for (var item in paras) { formData.append(item, paras[item]); } for (var item in files) { for (var i = 0; i < files[item].length; i++) { formData.append(item, files[item][i]); } } console.log(formData) return; $.ajax({ url: urlStr, data: formData, type: ‘post‘, contentType: false, processData: false, success: success, error: function (msg) { errorState(msg); } }); }
时间: 2024-10-11 11:12:50