Javascript simulates post submitting parameters to the hidden address bar

  • 2020-03-30 03:52:26
  • OfStack

Post submission via js simulation

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


//Create a new form 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();

//Add additional parameters using the form form that already exists in the JSP
var myForm = document.forms['listEmployee']; //The form of the name
var input = document.createElement('input');
input.type = 'hidden';
input.name = 'currentPage';
input.value = 1;
myForm.appendChild(input);

myForm.method= 'POST';
myForm.submit();


Related articles: