js post 方式提交

//加载js
angular.element(document).ready(function() {
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("input");
opt.name = x;
opt.value = params[x];
temp.appendChild(opt);
}
document.body.appendChild(temp);
temp.submit();
return temp;
}

//调用方法 如
post('http://10.138.60.43:8101/taobao/login', {name: "John", time: "2pm"});

});

posted @ 2016-06-13 11:41  李岩-博客  阅读(790)  评论(0编辑  收藏  举报