利用JS使用POST方式提交请求的方法
2015-04-22 10:19
615 查看
一般都是写上隐藏的form标签,用<a href="#" onclick="..."/>来调用js函数然后submit
全部用js来写也行,以下是我在一个问答频道看见别人写的例子,放在这里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];
// alert(opt.name)
temp.appendChild(opt);
}
document.body.appendChild(temp);
temp.submit();
return temp;
}
//调用方法 如
post('pages/statisticsJsp/excel.action', {html :prnhtml,cm1:'sdsddsd',cm2:'haha'});
相关文章推荐
- 利用JS使用POST方式提交请求的方法
- 利用JS使用POST方式提交请求的方法
- 利用JS使用POST方式提交请求的方法
- JS使用POST方式提交请求
- js超链接使用post方式提交----解决中文乱码
- 使用Post方式提交数据到Tomcat服务器的方法
- Android 网络请求方式之HttpClient,GET,POST,PUT请求使用方法
- 怎样利用JS提交POST请求
- android之使用get和post方式向服务器提交请求
- js AJAX请求的 $.post方法的使用
- android利用httpclient实现post、get请求restful接口进行json和form表单数据提交等公共方法类
- JS使用post提交的两种方式
- JS使用post提交的两种方式
- 使用HttpURLConnection通过POST方式提交请求数据,并上传文件
- JS实现使用POST方式发送请求
- 利用python模拟实现POST请求提交图片的方法
- android之使用get和post方式向服务器提交请求
- JS使用post方式提交
- Android 网络请求方式之HttpClient,GET,POST,PUT请求使用方法
- 如何使用nodejs提交表单方式的post请求?