新版jQuery使用ajax:
$.ajax({
'url': '/booktest/login_ajax_check/',
'type': 'post',
'data': {'username': username, 'password': password},
'dataType': 'json',
success: function (data) {
if(data.res == 0){
$('#errmsg').show().html('用戶名或密碼錯(cuò)誤')
} else {
location.href = '/booktest/home/'
}
}
})
舊版jQuery使用ajax:
$.ajax({
'url': '/booktest/login_ajax_check/',
'type': 'post',
'data': {'username': username, 'password': password},
'dataType': 'json',
}).success(function (data) {
if (data.res == 0){
$('#errmsg').show().html('用戶名或密碼錯(cuò)誤')
} else {
location.href = '/index'
}
})