How to send a POST request in window.open() function of JavaScript.

14 / Jun / 2010 by Chandan Luthra 0 comments

Hey,

Recently, I need to show some printing stuff using window.open() method of JavaScript. I got stuck when the implementation demands sending POST call to the server for generating the print view.

I googled a lot and found few JavaScript code snippets that provides some workaround for doing this stuff. Finally, I found some cool way for sending POST request in window.open(). I thought, it’ll be worth sharing.

Here is the code:

........................................................... ...................//input fields....................... ..........................................................

Notice the name of the window (‘myWindow’) is same as the name given in form’s ‘target’ attribute. On submitting this form, javascript will open a new window and the output of the form will get rendered in that window.

Hope this helps..

~Chandan Luthra~
chandan(AT)intelligrape(DOT)com

FOUND THIS USEFUL? SHARE IT

Leave a Reply

Your email address will not be published. Required fields are marked *