<a>标签模拟post提交方式
2013-11-12 10:27
197 查看
<a>标签模拟post提交方式
本人在项目中遇到要使用<a>标签发送post请求,现将解决方案整理如下:方法一:
1、编写javascript函数,模拟post提交:
function post(URL, PARAMS) { var temp = document.createElement("form"); temp.action = URL; temp.method = "post"; temp.style.display = "none"; for (var x in PARAMS) { var opt = document.createElement("textarea"); opt.name = x; opt.value = PARAMS[x]; temp.appendChild(opt); } document.body.appendChild(temp); temp.submit(); return temp; }2、在<a>标签中调用:
方式1:
<span style="font-family:KaiTi_GB2312; font-size:14px"><a href="javascript:post('${ctx}/system/user!toMain.action',{areaId:'${section.id}',chkId:'${role.id}'});" >• ${section.showName}-${role.roleName }</a></span>
方式2:
<span style="font-family:KaiTi_GB2312; font-size:14px"><a href="javascript:void(0);" onclick="post('${ctx}/system/user!toMain.action',{areaId:'${section.id}',chkId:'${role.id}'})" >• ${section.showName}-${role.roleName }</a></span>
相关文章推荐
- 【HTML】表单中<input>标签、组件格式化、表单提交方式、浏览器服务端交互方式
- <Basic>数据提交方式:post和get
- <form>标签提交不转跳的几种方式
- 数据抓取中post与get方式的处理深入理解(不用给网页标签赋值也不用模拟提交js)
- <form>标签提交不转跳的几种方式
- Struts2标签: 三种给<s:a>,<a>标签传值的方式
- Struts2标签: 三种给<s:a>,<a>标签传值的方式
- 再谈QT模拟点击<a>标签
- <a>标签跳转新页面的各种方式
- <<< 判断提交方式是get还是post
- C# Winform利用POST传值方式模拟表单提交数据(Winform与网页交互)
- <s:token />标签防止重复提交
- C# Winform利用POST传值方式模拟表单提交数据(Winform与网页交互)
- Struts2 <s:token/>标签 防止表单多次提交
- C# Winform利用POST传值方式模拟表单提交数据(Winform与网页交互)
- mysql insert一条记录(事务提交之前)怎样返回创建记录的主键id,last_insert_id(),selectkey && <select> 标签属性
- C# Winform利用POST传值方式模拟表单提交数据(Winform与网页交互)
- Javascript模拟FORM以POST方式提交表单数据
- 【HTML】怎样使用a标签以post方式提交
- 通过curl模拟post和get方式提交的表单类