I'm writing a script that when a button is clicked, will check by ajax if the user is logged in, and if so, do some actions without leaving the page. If the user is not logged in, I want to open a login window popup. THe problem is that since window.open() is not directly under the 'click' event, it gets blocked by popup blockers. If I put the window.open right under the click action, it works fine.
Any way around this?
$('.myButton').click(function() {
$.get(ajaxUrl, function(hastoken) {
if(hastoken == 1) {
// do stuff here
} else {
window.open("http://www.google.com");
// login
}
});
});