function post(path,params, method){
method = method ||"post";// Set method to post by default if not specified.// The rest of this code assumes you are not using a library.// It can be made less wordy if you use one.var form = document.createElement("form");
form.setAttribute("method", method);
form.setAttribute("action", path);for(var key inparams){if(params.hasOwnProperty(key)){var hiddenField = document.createElement("input");
hiddenField.setAttribute("type","hidden");
hiddenField.setAttribute("name", key);
hiddenField.setAttribute("value",params[key]);
form.appendChild(hiddenField);}}
document.body.appendChild(form);
form.submit();}
Example:
post('/contact/',{name:'Johnny Bravo'});
相关推荐
Javascript postMessage 用法 父级 已加载 必须将已加载的方法添加到iframe本身,目的是在加载iframe时添加一个标志。 < iframe id =" i_frame " src =" ... " onload =" nj(this).loaded() " > </ iframe...
本文实例讲述了Javascript使用post方法提交数据的方法。分享给大家供大家参考。具体如下: 使用JS提交数据时,可以调用本方法实现post方式的提交。 var jsPost = function(action, values) { var id = Math.random...
JSON数据前后传输例子,post,get请求例子,jquery
原生javascript实现ajax发送pos请求,这样可以脱离jquery框架,
通过js模拟post提交 1:请求需要的参数过长,超过get允许的最大长度 2:想要隐藏地址栏的参数 //新创建一个form表单 [removed]('<form name=myForm></form>'); var myForm=document.forms['myForm']; ...
ajax中使用javascript的send方法post参数。当用set方法是会出现中午乱码的问题,该文档说的post方法很好的解决了该问题,具体用法见文档
本篇文章主要介绍了JavaScript 跨域之POST实现方法,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
It will also show you some advanced patterns, including dependency injection and live post processing. The third module, Functional Programming in JavaScript, will help you to write real-world ...
JavaScript应用实例-qq群post签到.js
最近在用url 传特殊字符的时候发现数据丢失了。 其实不是丢失,比如 ‘+’它会当成连接字符来处理了。...var post_Str= post_Str.replace(/\&/g, “&″);//”&” var post_Str= post_Str.replace(/\#/g, “#″);//
PostCSS Javascript输出 插件,其他插件可以使用它来输出JavaScript代码。 postcss-javascript-output使您可以编写如下插件: module . exports = postcss . plugin ( 'postcss-helloworld' , function ( ) { return...
with HTML and CSS, and how to post them online.) 1 Do you hold a ninth degree black belt in Script Fu, and are really looking for a JavaScript reference book? 2 Are you afraid to try something ...
最近的一个项目中,需要通过 JavaScript 提交表单数据到另一个域名下的PHP接口(因为数据较大,需要HTTP POST方式提交),并获取PHP接口的返回值,在页面无刷新、无跳转的情况下,更新div标签内的内容。 浏览器...
Get information from visitors, help shoppers buy goods, and let members post their thoughts. Go beyond the browser with Ajax. Communicate with the web server to update your pages without reloading. ...
事后跨域事件处理程序javascript库。 纯香草JS,无依赖性。介绍该库的初衷是一个简单的目标:提供一种处理事件的简单方法,而无需付出多次编写特殊代码的麻烦,以防万一我们处于跨域情况。 向PostEvent打个招呼。...
解决vue $http的get和post请求跨域问题 vue $http的get和post请求跨域问题 首先在config/index.js中配置proxyTable proxyTable: { '/api':{ // target:'http://jsonplaceholder.typicode.com', target:'...
集成war包,跨域脚本,支持post方式提交大数据 提高跨域数据交互的安全性