js提交数据并打开新页面[window.open 以及form]

js提交数据并打开新页面[window.open 以及form]

  1. window.open打开新页面即便延迟10s,也可能会被浏览器拦截,不可取
$.ajax({    
          type: "POST",   
          url: '方法名',   
          data: orderInfo,  
 		  contentType: "application/x-www-form-urlencoded; charset=UTF-8",
          success: function(str_response) { 
 
			 setTimeout(function () { 
				var obj =  window.open("about:blank");  
	            obj.document.write(str_response);  
			 },6000); 
          }   

      });
  1. form表单提交
	var actionName = "方法名";
	var newForm = $("
"
).hide(); newForm.append($("").val(orderInfo['action'])); newForm.append($("").val(orderInfo['cp_order_no'])); newForm.append($("").val(orderInfo['role_id'])); newForm.append($("").val(orderInfo['server_id'])); newForm.appendTo($(document.body)); newForm.attr("action", actionName).submit().remove();

你可能感兴趣的:(jQuery)