原始ajax提交:
$.ajax({ type: "POST",data:"processId="+$("#processId").val()+"&delstepids="+delstepids,url: "./delStepForProcess.jspx",dataType: "text",cache: false,success: function(data){ if(1==data){ alert("删除失败!"); return; }else{ location.reload(); } } });
data:"参数1="+参数值
ajax提交form:
$.ajax({ type: "POST",data:$("#theForm").serialize(),url: "${basePath}/public/sjkf/serveyanswer/saveData.jspx",success: function(data){ if(1==data){ alert("删除失败!"); }else{ } } });
data:$("#form的id").serialize()
action(或者controller)中接受参数:
request.getParameter("token");
返回信息:
PrintWriter out = null; try { response.setCharacterEncoding("UTF-8"); response.setContentType("text/json;charset=UTF-8"); out =response.getWriter(); customProcessService.modifyStepToStart(processId,stepId); out.println("0"); } catch (Exception e) { out.println("1"); e.printStackTrace(); }finally{ if(out!=null){ out.close(); } }
<form action="" id="theForm" name="theForm" enctype="multipart/form-data" method="post" >
</form>
-----------------------------------------------------------------------------------------------------------------------
不能认怂.....................
原文链接:https://www.f2er.com/ajax/164527.html