js使用post请求

来源:互联网 发布:suse linux 编辑:程序博客网 时间:2024/05/16 01:51
  1. function post(URL, PARAMS) {         
  2.     var temp = document.createElement("form");         
  3.     temp.action = URL;         
  4.     temp.method = "post";         
  5.     temp.style.display = "none";         
  6.     for (var x in PARAMS) {         
  7.         var opt = document.createElement("textarea");         
  8.         opt.name = x;         
  9.         opt.value = PARAMS[x];         
  10.         // alert(opt.name)         
  11.         temp.appendChild(opt);         
  12.     }         
  13.     document.body.appendChild(temp);         
  14.     temp.submit();         
  15.     return temp;         
  16. }         
  17.         
  18. 调用方法 如         
  19. post('pages/statisticsJsp/excel.action', {html :prnhtml,cm1:'sdsddsd',cm2:'haha'});  
原创粉丝点击