2015-02-05 83 views
0

我想在电子邮件和密码正确的情况下重定向到其他页面。与我的脚本我能够或者用户输入了正确或错误的电子邮件和密码。当它的权利告诉“正确的电子邮件”,当它是错误的,它告诉“错误的电子邮件或密码”在“消息”div。使用ajax登录并重定向

现在我想要做的是当消息是“正确的电子邮件”用户应该被重定向到例如“inside.php”。我添加了哪些脚本来使其工作?

$(document).ready(function(){ 
    $("form").on('submit',function(event){ 
     event.preventDefault(); 

     data = $(this).serialize(); 
     $.ajax({ 
     type: "POST", 
     url: "login.php", 
     data: data 
     }).success(function(msg) { 
    $('#message').html(msg); 


     }); 
    }); 
}); 
+0

只需在成功回调中使用window.location.href = inside.php – 2015-02-05 13:43:46

+0

就可以了,使用window.location.href = desired_url – 2015-02-05 13:44:51

回答

0
$(document).ready(function(){ 
    $("form").on('submit',function(event){ 
     event.preventDefault(); 

     data = $(this).serialize(); 
     $.ajax({ 
     type: "POST", 
     url: "login.php", 
     data: data 
     }).success(function(msg) { 

    window.location.href = 'desired_url' ; 


     }); 
    }); 
}); 
上成功

,使用window.location.href = 'desired_url';

+0

那么我在哪里把这个论点放在对错之处呢?因为只有在信息正确的情况下,重定向才会被关闭。email – 2015-02-05 13:53:23

+0

your_url?msg =成功或任何你想要的 – 2015-02-05 13:54:44