JS in general new open window is very simple direct window.open (URL); it's OK,
But since I want to pass parameters to the server, and the parameters look a long string, and the length of the commit parameters of Get mode is limited, I have the following requirements:
Implement post submission in 1,js
2, the returned page is displayed in a new window
First of all, I did it:
Copy Code code as follows:
$.ajax ({
Type: "POST",
URL: ' ${contextpath}/analyse/detail.do ',
Data: {Carnum:carnum,ids:refids},
Success:function (str_response) {var obj = window.open ("About:blank");
Obj.document.write (Str_response);
}
});
Through jquery Ajax submission, the returned data is written in the new page, but because the browser will block the pop-up window, so that users need to lift their own interception, the user experience is very poor,
And then I did it by simulating the submission of form forms.
Copy Code code as follows:
Function post (URL, PARAMS) {var temp_form = document.createelement ("form");
Temp_form. Action = URL;
Temp_form. target = "_blank";
Temp_form. Method = "POST";
Temp_form. style.display = "None"; for (var x in PARAMS) {var opt = 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 newly opened window form to be set to ' _blank '
The
Then requests the post (' ${contextpath}/analyse/detail.do ', {carnum:carnum,ids:refids}); it's OK.