1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| var loadIndex = null; var vv='111'; var fileObj = $(_this)[0].files[0]; var form = new FormData(); form.append("file",fileObj); form.append("vv",vv);
$.ajax({ type:"POST", url:'请求地址', data:form, processData:false, contentType : false, dataType:'json', beforeSend: function () { loadIndex = layer.load(1, { shade: [0.1, '#fff'] }); }, complete: function () { layer.close(loadIndex); }, success:function (res) { if(res.status==200){ console.log(res); resfun(res.data); }else{ layer.msg(res.msg,{icon:2}); } }, error:function (xhr, type, errorThrown) { layer.msg('上传错误,代码'+xhr.status,{icon:2}); } });
|