var form = $("form[name=fileForm]"); $("#uploadTip").html("正在上传..."); var options = { action: '/optimizationJob/uploadFile.action',type: 'post',data: {fileName:fileName },//传递文件名到服务器 success: function (data) { var success = data.success; var errMsg = data.errMsg; if (success == "Y") { console.log("上传成功,返回success=Y,errMsg:" + errMsg); $("#uploadTip").html("上传成功"); // uploadFileToJSS(fileName); } else { console.log("上传失败,返回success=N,errMsg:" + errMsg); $("#uploadTip").html("上传失败"); } $("#submitBtn").attr("disabled",false); },error: function (data) { console.log("上传失败,返回error"); $("#uploadTip").html("上传失败"); $("#submitBtn").attr("disabled",false); } }; form.ajaxSubmit(options);
java中的Action写好fileName的set,get方法,就能使用了
原文链接:https://www.f2er.com/ajax/161056.html