Reputation: 401
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 == login
But it doesnt. please help thanks!
Upvotes: 1
Views: 115
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
Reputation: 2604
You missed the href
window.location.href="http://www.google.co.uk";
Upvotes: 5