servlet ajax 返回

<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

    }

 

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值