JS代码其实很简单:
$('#loginForm').submit(function() {
var account, password;
account = $('#account', '#loginForm').val();
password = $('#password', '#loginForm').val();
$.post("/index.php/login/validate", { 'account': account, 'password': password },
function(data){
$('#msg').html(data);
alert(data + '----' + parseInt(data));
if (parseInt(data) == 0)
{
window.location = '/index.php/notice/load';
}
else
{
alert('密码错误');
}
});
return false;
});
Controller:
function validate()
{
echo '0';
} |