Open popup window with post request data in Javascript

 Open popup window with post request data using javascript:
                              
  function openWindowWithPostRequest() {
           var winName='MyWindow';
           var winURL='search.action';
           var windowoption='resizable=yes,height=600,width=800,location=0,menubar=0,scrollbars=1';
           var params = { 'param1' : '1','param2' :'2'};           
           var form = document.createElement("form");
           form.setAttribute("method", "post");
           form.setAttribute("action", winURL);
           form.setAttribute("target",winName); 
           for (var i in params) {
                 if (params.hasOwnProperty(i)) {
                     var input = document.createElement('input');
                     input.type = 'hidden';
                     input.name = i;
                     input.value = params[i];
                     form.appendChild(input);
                 }
           }             
           document.body.appendChild(form);                                   
           window.open('', winName,windowoption);
           form.target = winName;
           form.submit();                  
           document.body.removeChild(form);          
   }
                               

Popular posts from this blog

Can not connect to git using ssh (Permissions 0644 for '/root/.ssh/id_rsa' are too open.

Upload file on Google cloud storage using Java servlet on google app engine

Session timeout interceptor in struts 2