I am working with Firefox. Why window.open() does not work with Ajax? How to fix it? But,it works without Ajax. Please see the code underlined.
Please see the code below.
I want window.open() working in the success of Ajax. how to fix it? Thanks.
Please see the code below.
Code:
$("#button_MN_invite").on("click", function() {
var tester = true
if ($('#input_MN_invitees_email_ids').val() != "") {
//$("#button_MN_invite").unbind("click");
$("#button_MN_invite").attr('disabled', 'disabled');
emails = $('#input_MN_invitees_email_ids').val().replace(/\s+/g, "");
$.each(emails.split(",").slice(0), function(index, item) {
if (!MN_emailValidation(item)) {
tester = false;
//$("#button_MN_invite").bind("click");
$("#button_MN_invite").removeAttr('disabled', 'disabled');
alert('Check valid Email Address for \'' + item+'\'');
return false;
};
});
if (!tester) {
//$("#button_MN_invite").bind("click");
$("#button_MN_invite").removeAttr('disabled', 'disabled');
return false;
}
//console.log('um not out of function');
key = $("#MN_room_key").attr("value");
$.ajax({
type : "post",
url : "http://"+hoster+"/meetnow/inviteToRoom",
crossDomain : true,
data : {
emails : emails,
adminemail : $.session.get('roomCrtrMid'),
key : key,
hangout_id : $("#MN_room_id").attr("value"),
roomname : $("#MN_room_name").attr("value"),
pleaseuseme : "invite.php",
userhost : hoster
},
beforeSend : function(){
$("#loading").show();
},
complete : function(){
$("#loading").hide();
},
success : function(result) {
if (result == "yes") {
$("#loading").hide();
//alert("Invitation sent successfully.");
//window.location = "/meetnow/login.html#" + $("#MN_room_key").attr("value");
var newurl = "http://64.34.67.46/meetnow/login.html#"+$("#MN_room_key").attr("value");
var [B][I][U]win = window.open(newurl, '_blank'); // not working here [/U][/I][/B]
} else if (result == 'no') {
$("#loading").hide();
//$("#button_MN_invite").bind("click");
$("#button_MN_invite").removeAttr('disabled', 'disabled');
alert("Programming error, while passing arguments.");
} else {
$("#loading").hide();
//$("#button_MN_invite").bind("click");
$("#button_MN_invite").removeAttr('disabled', 'disabled');
alert("There was a problem in sending invitation.");
}
}
});
[B][I][U]window.open("http://64.34.67.46/meetnow/login.html#"+$("#MN_room_key").attr("value"), '_blank');[/U][/I][/B] // it works well here.
} else {
//$("#button_MN_invite").bind("click");
$("#button_MN_invite").removeAttr('disabled', 'disabled');
alert("Please enter Email address and then proceed.");
}
});
Comment