Window.open is blocked
I found another thread on stackoverflow: popup window.open blocked during click event . And the main answer seems to solve the problem. But I don't know much JavaScript.
Can you help me rewrite the code according to the answer:
1) Call window.open
just before the call $.ajax
and keep the link to the window:
var newWindow = window.open(...);
2) In the callback setpoint definition property of the saved window reference:
newWindow.location = url;
Perhaps this is already explicitly. But I don't know how to rewrite the code.
source to share
Well, keeping in mind the context of the question you linked, it would be something like this:
var newUrl = 'http://example.com';
var newWindow = window.open('', '_blank');
$.ajax({
type: "POST",
url: form_url,
dataType: 'json',
data: form_data,
success: function(data) {
newWindow.location = newUrl;
}
});
Of course, you will need to modify the call $.ajax
(URL and data in particular) to suit your requirements.
source to share