How to send a POST request in window.open() function of JavaScript.
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:
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