当前位置:Gxlcms > JavaScript > javascript模拟post提交隐藏地址栏的参数

javascript模拟post提交隐藏地址栏的参数

时间:2021-07-01 10:21:17 帮助过:3人阅读

通过js模拟post提交

1:请求需要的参数过长,超过get允许的最大长度
2:想要隐藏地址栏的参数

  1. //新创建一个form表单
  2. document.write('<form name=myForm></form>');
  3. var myForm=document.forms['myForm'];
  4. myForm.action='runEmpAttendance';
  5. myForm.method='POST';
  6. var input = document.createElement('input');
  7. input.type = 'text';
  8. input.name = 'userId';
  9. input.value = 100;
  10. myForm.appendChild(input);
  11. myForm.submit();
  12. //使用jsp中已经存在的form表单,添加其他的参数
  13. var myForm = document.forms['listEmployee']; //表单的name
  14. var input = document.createElement('input');
  15. input.type = 'hidden';
  16. input.name = 'currentPage';
  17. input.value = 1;
  18. myForm.appendChild(input);
  19. myForm.method= 'POST';
  20. myForm.submit();

人气教程排行