ajax提交文件
2021-03-20 01:24
标签:multipart else return pdf document xmlhttp style ror ret $("#file").off("change").on("change",function(){ ajax提交文件 标签:multipart else return pdf document xmlhttp style ror ret 原文地址:https://www.cnblogs.com/foreverstudy/p/12744281.html
var inputFile = $(‘#file‘).get(0).files[0];
if(inputFile && (inputFile.name.endsWith("doc") || inputFile.name.endsWith("docx"))){
$("#span").html(inputFile.name);
}else{
window.wxc.xcConfirm("请上传word文件!", "error");
return ;
}
});
$("#BA_Btn").click(function(){
var s=$("#span").html();
var form = new FormData(document.getElementById("addForm"));
$.ajax({
type: "POST",
url: "backend/sjxq/add",
data: form,
async: false,
processData: false,
contentType: false,
success: function (result) {
window.history.back();
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
window.wxc.xcConfirm("保存失败", "error");
return ;
},
});
});