jquery或js前端提交数据的几种方式
jquery提交数据的方式: 第一种jquery序列化提交数据方式: 通过id获取的form表单元素.serialize(); 第二种模拟form表单提交元素: $(\'#form表单id\').attr(\'method\',\'post\'); $(\'#form表单id\'\').find(\'input[name="type"]\').val(test); $(\'#form表单id\').find(\'input[name="dfrom_to1"]\').val(dfrom_to); $(\'#form表单id\').find(\'input[name="gt_road_new"]\').val(gt_road); $(\'#form表id\').attr(\'action\',AdminLTE.ctx+\'/modules/ltegt/findAllCoverAndInterfere.do\'); $(\'#analysisForm\').submit();
js提交数据的方式: 1.js提交表单( .submit()方法提交表单 ) function doSearch(){ var action ="<%=path%>/User_queryAllUser"; document.all.form.action = action; document.all.form.submit(); } 2.js提交表单( .submit()方法提交表单 ) <script type="text/javascript"> function addSubmit() { var targetForm = document.forms[ "form1" ]; targetForm.action = "logo.do?method=downAdd"; targetForm.submit(); } </script> <form name="form1" method="post" action="logo.do" enctype="multipart/form-data"> 3.js替代超链接( window.location.href ) <input type="button" id="modify" value="修改工号" onclick="modifyEmp(${ myList.employeeId })"> //js不能起名为modify,为敏感关键字 function modifyEmp( employeeId ){ //employeeId 作为js的参数传递进来 window.location.href = \'<%=path%>/User_openUserUpdate?employeeId=\'+employeeId; }