Google Chrome seems to be blocking a popup I am creating via jQuery. After some investigation, it appears to be an issue with calling window.open
in the success event of an ajax call. Is there a way around this? My jQuery ajax call returns the URL to be opened. So I am bit stuck.
It works if I place the window.open
outside the ajax call; but, inside (i.e. in the success event) it is blocked. I think it is something to do with CONTEXT but I am unsure.
Here is what I have:
window.open("https://www.myurl.com"); // OUTSIDE OF AJAX - no problems
// with popup
$.ajax({
type: "POST",
url: "MyService.aspx/ConstructUrl",
data: jsonData,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
// Normally loads msg.d which is the url returned from service
// static url below is for testing
window.open("https://www.myurl.com"); // THIS IS BLOCKED
},
error: function(msg) {
// alert(error);
}
});