js提交请求的几种方式
我们经常需要通过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;
}