Get all the data of the form, submit juqery, open window.open, the current page does not jump

$(function(){
 $('#preview').click( function(){ 
 var array=$("#inputForm").serializeArray();

   openPostWindow("at_km_info!preView.action",array,"mywin" );
 
    } );
   
 
function openPostWindow(url, data, name) {      
   
     var tempForm = $("<form id='tempForm1' method='post' />");      

     //url 
     tempForm.attr('action',url);       
     tempForm.attr('target',name);      
    $.each(data,function(i,arr){

   var hideInput = $("<input type='hidden'/>");      
   hideInput.attr('name',arr.name);
   hideInput.attr('value',arr.value);
   hideInput.appendTo(tempForm);  

 });
     
   alert(tempForm.html());
 
      tempForm.appendTo($('body'));       tempForm.submit(openWindow(name));        $(tempForm).remove();     }     function openWindow(name) {   
       

   

   
   
   

        var width = 1000;
        var height = 600;
        var left = parseInt((screen.availWidth/2) - (width/2));//屏幕居中
        var top = parseInt((screen.availHeight/2) - (height/2));
        var windowFeatures = "width=" + width + ",height=" + height + ",status,resizable,left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top;
        window.open('',name,windowFeatures);
}      

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325841112&siteId=291194637