js伪表单提交代码

时间:2022-11-21 09:39:32
function jumpKYB(){
var teamId = $("#secretTeamId").val();
var coreCode = $("#secretCoreCode").val();
var userName = $("#secretUserName").val();
var persontypeid = $("#persontypeid").val();
var channeltype = $("#channeltype").val();
post('http://XXXXX',{comcode:teamId,usercode:coreCode,username:userName,handler1code:coreCode,channeltype:channeltype,operatorcode:coreCode,persontypeid:persontypeid});
}

function post(URL, PARAMS) {
  var temp = document.createElement("form");
  temp.action = URL;
  temp.method = "post";
  temp.style.display = "none";
  temp.target = "_blank";
  for (var x in PARAMS) {
    var opt = document.createElement("input");
    opt.name = x;
    opt.value = PARAMS[x];
    //alert(opt.name+":"+opt.value);
    temp.appendChild(opt);
  }
  document.body.appendChild(temp);
  temp.submit();
  return temp;
}