<script type="text/JavaScript">
?
var xmlhttprequest;
function CreateRequest()
{
??? if(window.ActiveXObject){
??????? return new ActiveXObject("Microsoft.XMLHTTP");
??? }else if(window.XMLHttpRequest){
??????? return new XMLHttpRequest();
??? }
}
?
function CheckUser(){
??? var vuid=document.getElementById("textfield").value;?
??? var vpass=document.getElementById("textfield2").value;
??? var vauthorn=document.getElementById("choicefield").options[window.document.getElementById("choicefield").selectedIndex].value;
?
??? if((vuid=='')||(vpass=='')){
??? ??? if(vuid==''){
??? ??????? alert("用户名不能为空!");
??? ??? }else if(vpass==''){
??? ??????? alert("密码不能为空!");
??? ??? }else {
??? ??????? alert("请输入有效的用户名和秘密!");
??? ??? }
??? }else{???????
??? ??? var url="/Obj_BMS/servlet/logincall?vuid="+vuid+"&vpass="+vpass+"&vauthorn="+vauthorn;
?
??? ??? xmlhttprequest=CreateRequest();
??? ??? xmlhttprequest.onreadystatechange=HaoLeJiaoWo;
??? ??? xmlhttprequest.open("POST",url,true);
??? ??? xmlhttprequest.send(null);
??? }
???
}
function HaoLeJiaoWo()
{
???
??? if(xmlhttprequest.readyState==4)
??? {
??
??????? if(xmlhttprequest.status==200)
??????? {
?
?????????? var vreturn=xmlhttprequest.responseText;
?????????? switch(parseInt(vreturn)){
?????????? ????case 1:
?????????? ???? ????????window.location.href="/Obj_BMS/servlet/bookclass";
?????????? ???? ???????break;
?????????? ????case 2:
?????????? ???????????? window.location.href="/Obj_BMS/pagelibr/librinfo.jsp";?
?????????? ???????? ???break;
?????????? ???? case 3:
?????????? ???????????? window.location.href="/Obj_BMS/pagebbms/addbook.jsp";????
?????????? ???????? ???break;
?????????? ????default:
?????????? ??????????? alert("??? 用户名或密码有误\n请输入正确的用户名和密码!");
?????????? ??????????? MM_clickempty();
??????????????????? ?? break;
?????????? }??????????
??????? }
??? }
}
</script>
?
=============servlet ajax 返回out.println(objreturn);==============
???????
??????????????? ??? objreturn=dbid+"~"+dbname+"!"+dbauthor+"@"+dbpublish+"#"+dbcount+"$"+dbphoto+"^"+dbmark+"|";??????? ???????????
??????????????? }
??????????? }catch(Exception e){
??????????????? e.printStackTrace();
??????????? }finally{
??????????????? ConnectionManager.closeConnection(con);
??????????? }
??????????? //out.println(objary);
??????????? out.println(objreturn);
???????
??????? out.flush();
??????? out.close();
??? }
???
??? /**
??? ?* Initialization of the servlet. <br>
??? ?*
??? ?* @throws ServletException if an error occurs
??? ?*/
??? public void init() throws ServletException {
??????? // Put your code here
??? }
?
}