I have an ajax call through jQuery; when it completes I need to open an URL in a new tab.
I wrote this simple function:
var openWin = function() {
window.open('/UrlToOpen', '_blank');
win.focus();
}
If I call this function directly from JS code, it opens without triggering the pop-up blocker.
If I call it from $.ajax().done(), like this:
$.ajax({
url: 'ajaxUrl',
type: 'POST'
}).done(function (result) {
openWin();
});
The pop-up blocker is triggered.
Demonstration here: https://jsfiddle.net/dggwL5uj/
Why? How can I avoid this?