Implementing post in JavaScript delivers submit data

Source: Internet
Author: User

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_r_relement_x ("form");
Myform.method = "POST";
Myform.action = to;
For (var k in P) {
var myinput = document.create_r_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>



Code for Hyperlinks:

The code is as follows Copy Code

<a href= "Javascript:postwith (' datatest.action ', {' currentpage ': ' 2 ', ' Xisuo ': ' Computer '})" >use JS to Post</a>


When you click the hyperlink, you can send the value of CurrentPage and Xisuo to the datatest.action for processing, especially when handling multiple parameters.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.