How do I Open window.open in the same TAB
- 2020-03-30 03:24:01
- OfStack
If you have Ajax, set it
async:false,//Synchronize the AJax
var countdownInterval;
function ToRecharge(){
var paramData = new Object();
paramData.PayType = 1;//Alipay pay
paramData.OrderMoney = parseFloat($("#spShouldPay").text());//Total payment
var gprsTel = [];
var orderDetail = new Array();
for(var i = 0; i < deviceList.length; i++){
orderDetail[i] = new Object();
orderDetail[i].DeviceSN = deviceList[i].DeviceSN;//Equipment of SN code
orderDetail[i].GPRSTel = deviceList[i].GPRSTel;//GPRS mobile phone number
orderDetail[i].PayYear = parseInt($("#hdnYear").val());// Number of years
orderDetail[i].PayPotency = 100;//The default is 200 yuan
gprsTel.push(deviceList[i].GPRSTel);
}
paramData.GPRSTel = gprsTel.join(",");
paramData.OrderDetail = $.toJSON(orderDetail);
paramData.rand = Math.random();
paramData.PostType = "AddRecharge";
$.ajax({
url: '/App_Ajax/Service.ashx',
data: paramData,
type: 'post',
async:false,//Synchronize the AJax
success: function(resultData){
var jsonResult = $.parseJSON(resultData);
if(!jsonResult.success){
window.$.messager.alert(' prompt ', " Recharge record saving failed! ");
newwindow.close();
return;
}
$("#backupdate").text(" Return to modify ");
$("#timerecharge").hide();
$("#onrecharge").show();
$("#rechargesuccess").hide();
$("#hdnOrderStatus").val(jsonResult.obj.OrderStatus);
$("#hdnOID").val(jsonResult.obj.OID);
//Start a poll to continue reading OrderStatus of the Recharge_Order table and stop if successful
CheckOrderStatus(jsonResult.obj.OID);
//window.open("http://www.baidu.com");
openPostWindow(String.format("http://{0}/Default/Service/Recharge.aspx", location.host), $.toJSON(jsonResult.obj), "_blank")
}
});
}
function openPostWindow(url, data, target) {
var tempForm = document.createElement("form");
tempForm.id = "tempForm1";
tempForm.method = "post";
tempForm.action = url;
tempForm.target = target;
var hideInput = document.createElement("input");
hideInput.type="hidden";
hideInput.name= "PostName"
hideInput.value= data;
tempForm.appendChild(hideInput);
document.body.appendChild(tempForm);
tempForm.submit();
document.body.removeChild(tempForm);
}