我被困在 Jqueryajax 中,虽然它可以工作,但它并没有检查我所有的 if 条件。这是我使用 jQueryAjax 的代码:
jQuery.ajax({
type: "POST",
//data: 'user= ' + user + ' &pwd= ' + pwd,
url: "jsp/admin/master/Connectteacher.jsp?tuser="+tuser+"&tpwd="+tpwd,
async: false,
cache: false,
success: function( check ) {
if ( $.trim( check ) == 'new' ) {
window.location.replace("jsp/admin/master/Newuser.jsp?name="+tuser);
}
if ( $.trim( check ) == 'proceed') {
window.location.replace("jsp/admin/master/teacher-profile.jsp");
}
if ( $.trim( check ) == 'block') {
$('#teacherError').html("You are blocked!");
}
if ( $.trim( check ) == 'incorrect') {
$('#teacherError').html("Incorrect username or password");
}
}, error: function() {
$('#teacherError').html("database not connected");
}
});
这是我的 Connectteacher.jsp:
LoginTeacher l = new LoginTeacher();
String i = l.teacherAuthentication(request.getParameter("tuser"), request.getParameter("tpwd"));
char chusr = i.charAt(1);
char atmpts = i.charAt(0);
int at = Character.getNumericValue( atmpts );
System.out.println("matters" + at);
if( chusr == 'T' && at < 4 ) {
out.print("new");
}
if( chusr == 'F' && at < 4 ) {
System.out.println("inside old");
out.print("proceed");
}
if( at > 3 ) {
out.print("block");
}
//if(chusr==' ')
//{
//out.print("incorrect");
//}
它适用于前 3 个 if 条件,但当我包含第四个时则不行。是否有任何限制,我们只能在 jQueryAjax 中使用有限的 if 条件。请帮我