JS Post mode new open window

Source: Internet
Author: User

JS in general new open window very simple direct window.open (URL);

But because I want to pass parameters to the server, and the parameters look a long string, and the Get method has a limited length of commit parameters, I have the following requirements:

Implementing post Submissions in 1,js

2, the returned page is displayed in a new window

First of all, I did this:

$.ajax ({                        "POST",                        ' ${contextpath}/analyse/detail.do ',                        data: {carnum:carnum,ids : Refids},                        function(str_response) {                           var obj = window.open ("About:blank" );                           Obj.document.write (Str_response);                        }                    

By jquery Ajax submission, the returned data is written in a new page, but because the browser will intercept the automatic pop-up window, which also requires users to unblock themselves, the user experience is poor,

Then I do this by simulating the submission of form forms.

functionPost (URL, PARAMS) {varTemp_form = document.createelement ("form"); Temp_form. Action=URL; Temp_form. Target= "_blank"; Temp_form. Method= "POST"; Temp_form. Style.display= "None";  for(varXinchPARAMS) {                      varopt = document.createelement ("textarea"); Opt.name=x; Opt.value=Params[x];                  Temp_form. appendchild (opt);                  } document.body.appendChild (temp);             Temp_form. Submit (); }      

Note: If you want the target property of the new open window form to be set to ' _blank '

Then request post (' ${contextpath}/analyse/detail.do ', {carnum:carnum,ids:refids});

JS Post mode new open window

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.