1👍
Close the window in the callback function of $.get
.
$.get ('../../delete_function/', {delete_id:deleteid}, function(){
window.close();
});
Your if (clicked == true)
is only running when the page is loaded, because it’s not inside any event handler. At that point, the button obviously hasn’t been clicked yet, so it doesn’t do anything.
If you call window.close()
directly from the click handler, it will close the window before the AJAX call has a chance to run. When you close a window, all script it was running, including any AJAX operations that were queued, are killed.
Source:stackexchange.com