1

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!

4

2 回答 2

5

你错过了href

window.location.href="http://www.google.co.uk";
于 2013-04-29T10:56:03.043 回答
0

如果你想重定向到一个新页面,你可以写这个。window.open( http://www.google.co.uk ,"_parent","toolbar=no, location=no, directory=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width =1000,高度=850");

如果您想打开另一个窗口而不清除当前窗口的内容,请使用 window.open( http://www.google.co.uk ,"_blank","toolbar=no, location=no,directorys=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=1000, height=850");

于 2013-04-29T13:06:43.390 回答