【发布时间】:2018-07-16 12:53:52
【问题描述】:
我正在使用这样的 ajax post call,
$("#submit").on('click',function(){
$("#submit").prop("disabled",true);
$("#submit").prop("value","Loading...");
$.ajax({
type: 'POST',
url: 'myURL',
data: JSON.stringify({
"mailid" : mailid,
"a1" : a1,
"a2" : a2,
"a3" : a3,
"a4" : a4,
"a5" : a5,
"a6" : a6,
"a7" : a7,
"a8" : a8,
"a9" : a9,
"a10" :a10,
"dob" : age,
"filledBy" : filledBy
}),
success: function () {
//to open the score page
window.open("score.html","_top");
$("#submit").prop("disabled",false);
$("#submit").prop("value","Get My Score");
},
error: function(error) {
alert(error);
}
});
});
在成功函数中 window.open() 在 chrome 中工作正常,即页面被重定向到 score.html 但它在边缘、Firefox 和 Internet Explorer 浏览器中不起作用,而只是刷新同一页面。是否有另一种使用 window.open() 的方法,以便无论使用什么浏览器,它都会重定向到“Score.html”?
【问题讨论】:
-
你能在 jsfiddle 提供一个例子吗?谢谢。
-
那么问题是ajax成功还是
window.open?如果您只是在点击事件中添加window.open会怎样?它适用于所有浏览器吗? -
如果真的进入成功方法,听起来就像一个弹出窗口拦截器
-
是的,我相信这是一个弹出窗口阻止程序,我尝试在我的 ajax 方法中添加“async:false”,window.open() 工作正常,但添加 async:false 不会让这两行通过 , $("#submit").prop("disabled",true); $("#submit").prop("value","加载中...");有没有办法在不使用 async:false 的情况下防止弹出窗口阻止程序?
标签: javascript jquery