Javascript window.open not working

Viewed 70110

Ok. I'm trying to login to twitter. The window is not opening in this code. The response that gets alerted is not null and is a link to a login screen. Any ideas?

var url = "./twitter_login.php";
var con = createPHPRequest();

con.open("POST",url,true);
con.setRequestHeader("Content-type","application/x-www-form-urlencoded");
con.send("");

var response = "";

con.onreadystatechange = function() {

    if(con.readyState==4 && con.status==200) {

        response = con.responseText;    
        alert(response);
        window.open(response,"twitter","menubar=1,resizable=1,width=350,height=500");        

    }

}
2 Answers

Just had this exact same issue. Just in case you wanted the code that fixed it. I used this:

newWindow = window.open("", "_blank");

request = $.ajax({ ... my request which returns a url to load ... })

request.done((function(_this) {
        return function(data, textStatus, jqXHR) {
          return newWindow.location = data.Url;
        };
      })(this));
Related