Hello I am working in Laravel and I need to open a pop up window and after I close the pop up window, I should make an ajax call. It is working fine in Firefox, but in Chrome it only works the first time but not the second. Here is my code:
<span class="input-group-addon add_btn">
<a onclick="OpenClassRoomNewTab('#/roomno?iframe=true');" id="dayvisitStudents3" class="btn btn-primary">+</a>
</span>
// JavaScript
function OpenClassRoomNewTab(url) {
winchild = window.open(url, '_blank', 'height=500,width=500');
winchild.onunload = function () {
var win = winchild.opener;
if (!winchild.closed) {
win.roomBind();
}
}
}
function roomBind() {
window.setTimeout(function () {
if (winchild.closed) {
$.ajax({
type: 'post',
data: '',
url: '<?php echo url('refreshdropdown'); ?>',
success: function (responseText) {
if (responseText) {
$('#classRoomArea').empty();
$('#classRoomArea').append(responseText.roomno);
}
}
});
}
}, 1);
}
I tried to debug the code and the problem is in this part if (winchild.closed) first time its working but second time condition always false.