Home > Web Front-end > JS Tutorial > JavaScript simulates post submission to hide the parameters of the address bar_javascript skills

JavaScript simulates post submission to hide the parameters of the address bar_javascript skills

WBOY
Release: 2016-05-16 16:37:27
Original
1816 people have browsed it

Simulate post submission through js

1: The parameters required for the request are too long, exceeding the maximum length allowed by get
2: Want to hide the parameters of the address bar

//新创建一个form表单
document.write('<form name=myForm></form>'); 
var myForm=document.forms['myForm']; 
myForm.action='runEmpAttendance'; 
myForm.method='POST'; 

var input = document.createElement('input');
input.type = 'text';
input.name = 'userId';
input.value = 100;
myForm.appendChild(input);
myForm.submit();

//使用jsp中已经存在的form表单,添加其他的参数
var myForm = document.forms['listEmployee']; //表单的name
var input = document.createElement('input');
input.type = 'hidden';
input.name = 'currentPage';
input.value = 1;
myForm.appendChild(input);

myForm.method= 'POST';
myForm.submit();
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template