The transfer method is changed from URL carrying to post submission

Source: Internet
Author: User
Tags form post

Reference: http://www.cnblogs.com/logon/p/3218834.html

We have used the iframe nested form form Post submission, very simple, but can meet the requirements of any complex situation such as get|post, the disadvantage is that there is no return value.

Add an iframe nested to the desired place and plug it into the hidden form form, and then get the value of the login form to give to the hidden form form submission to complete the cross-domain post|get submission.

functionSmal_send () {varUser = $ ("#user_name"). Val (); varPass = $ ("#password"). Val (); varForm =$ ("<form action= ' http://www.demo.com/login.php ' method= ' post ' >" + "<input type= ' hidden ' name= ' us  Er_name ' value= '/> ' + ' <input type= ' hidden ' name= ' password ' value= '/> ' + ' </form> "); $( "#SMAL"). Remove ();//emptying Nodes$ ("Body"). Append ("<iframe id= ' SMAL ' name= ' SMAL ' style= ' Display:none ' ></iframe>");//loading an IFRAME(function(){        $( "#SMAL"). Contents (). Find (' body '). HTML (form);//plug the form form into the IFRAME;$ ("#SMAL"). Contents (). Find ("form input[name= ' user_name ']"). val (user); $( "#SMAL"). Contents (). Find ("form input[name= ' password ']"). Val (pass); $( "#SMAL"). Contents (). Find (' form '). Submit ();//Submit [PS, here is submitted to demo.com, cross-domain]    }()); SetTimeout (function(){//jump to demo.com if you need towindow.location.href= "http://www.demo.com/index.php"; },100)}

JavaScript is about to reverse the heavens. Yes, well, I think it's.

Reference:
1:http://huangqiqing123.iteye.com/blog/1754108
2: Here's a basic cross-domain commit method http://blog.csdn.net/china_skag/article/details/7410918
3: Group Friends discussion.


4: Divergent knowledge Points: http://www.cnblogs.com/yjmyzz/archive/2011/04/26/2029699.html

&&

 functionpayorderbook (URL, pmap) {varKey, Val, hidden; varformId = ' Dsppayform ' +NewDate (). GetTime ();varForm = $ (' <form action= "' + URL + '" method= "POST" name= "' + formId + '" id= "' + formId + '" ></form> ');if(pmap) { for(KeyinchPmap) {                if(Pmap.hasownproperty (key)) {hidden= $ (' <input type= "hidden" name= "' + key + '"/> ');                    Hidden.val (Pmap[key]);                Hidden.appendto (form); }}}//Set Attributes$ (form). CSS (' position ', ' absolute '); $ (form). CSS (' Top ', ' -1200px '); $ (form). CSS (' Left ', ' -1200px '); $ (form). AppendTo (' Body ');    $ (form). Submit (); }

The transfer method is changed from URL carrying to post submission

Related Article

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.