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);          
   }
                               

Comments

Popular posts from this blog

Struts 2 : Warning :No configuration found for the specified action: 'Login.action' in namespace: '/'

Upload csv file at Google Cloud Storage using java

Read Images from a xlsx file using Apache POI