shell
shell

Reputation: 401

ajax redirect does not work

I have a Login form where there are two fields - username and password. I am using ajax to send this variables to login.php which works. Now I need to get the data back from login.php so I do this:

$.post('login.php',{username:username,password:password},
 function(data)
 {
    $('#data').html(data);
    if (data=='login'){
        window.location="http://www.google.co.uk";

    }

 });

The problem is the code should redirect to http://www.google.co.uk if only the data is == loginBut it doesnt. please help thanks!

Upvotes: 1

Views: 115

Answers (2)

Sairam Venkata
Sairam Venkata

Reputation: 356

You can write this if you want to redirect to a new page. window.open(http://www.google.co.uk,"_parent","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=1000, height=850");

If you want to open another window without clearing the contents of the present window,use window.open(http://www.google.co.uk,"_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=1000, height=850");

Upvotes: 0

vinothini
vinothini

Reputation: 2604

You missed the href

window.location.href="http://www.google.co.uk";

Upvotes: 5

Related Questions