Jspost is actually very easy to submit data. We only need to create a form using js and set form method to post. We have organized the following two instances and hope to help you.
Example 1
| The Code is as follows: |
Copy code |
|
Var myForm = document. createElement ("form ");
MyForm. method = "get ";
MyForm. action = "line_ticket.aspx ";
Var myInput = document. createElement ("input ");
MyInput. setAttribute ("name", "id ");
MyInput. setAttribute ("value", idStr );
MyForm. appendChild (myInput );
Var myInput2 = document. createElement ("input ");
MyInput2.setAttribute ("name", "fid ");
MyInput2.setAttribute ("value", fid );
MyForm. appendChild (myInput2 );
Var myInput3 = document. createElement ("input ");
MyInput3.setAttribute ("name", "unlock ");
MyInput3.setAttribute ("value", unlock );
MyForm. appendChild (myInput3 );
Var myInput4 = document. createElement ("input ");
MyInput4.setAttribute ("name", "Option ");
MyInput4.setAttribute ("value", "del ");
MyForm. appendChild (myInput4 );
Document. body. appendChild (myForm );
MyForm. submit ();
Document. body. removeChild (myForm ); |
Example 2
| The Code is as follows: |
Copy code |
<Script type = "text/javascript">
Function postwith (to, p ){
Var myForm = document. create_r_relement_x ("form ");
MyForm. method = "post ";
MyForm. action =;
For (var k in p ){
Var myInput = document. create_r_relement_x ("input ");
MyInput. setAttribute ("name", k );
MyInput. setAttribute ("value", p [k]);
MyForm. a (myInput );
}
Document. body. a (myForm );
MyForm. submit ();
Document. body. removeChild (myForm );
}
</Script>
|
Hyperlink code:
| The Code is as follows: |
Copy code |
<A href = "javascript: postwith ('est est. action ', {'currentpage': '2', 'xisuo': 'computer '}) "> use js to post </a>
|
After clicking the hyperlink, you can send the values of currentPage and xisuo to datatest. action in the form of post for processing, especially when processing multiple parameters.