When a user clicks a button in my application, an ajax request is triggered. Following the success of this request, I generate a URL which I intend to open in a new tab. Unfortunately, when using Chrome and calling window.open within the success handler, the URL opens as a popup and gets blocked by popup blockers. It seems that Chrome may be mistakenly categorizing the asynchronous success code as not directly caused by the initial click event. Is there any way to address this issue without switching to synchronous ajax requests?
UPDATE Below is a snippet of code illustrating this problem:
$('#myButton').click(function() {
$.ajax({
type: 'POST',
url: '/echo/json/',
data: {'json': JSON.stringify({
url:'http://google.com'})},
success: function(data) {
window.open(data.url,'_blank');
}
});
});
It is worth noting that my main concern is the URL opening in a separate window rather than a tab, rather than its blockage by popup blockers.