我把AJAX调用的ASP文件打到IE地址栏里面写上必要的参数,页面能够正常打印出我需要的内容的。
但是现在的问题就是回调函数没有执行,里面放1个alert(1)也不执行。请问这是为什么,我其他地方用AJAX都正常的,就是这个函数不行。

解决方案 »

  1.   

    我其他地方用AJAX都正常的,就是这个函数不行。已经有焦点了
      

  2.   

    用jquery试试
    $(document).ready(function(){
    var a=false;
    var b=false;
    $("#username").blur(function(){
    var name=$("#username").val();
    if(name==""||name==null){
    $("#name").html("<font color='red'>请输入用户名! </font>");
     a=false;
    }else if(!/^[a-zA-Z0-9_]{4,16}$/.test(name)){
    $("#name").html("<font color='red'>输入格式不正确! </font>");
    a=false;
    }else{
    $.get("LoginAjaxName?username="+encodeURI(encodeURI(name)),null,function(response){
    $("#name").html(response);
    if(response=="<font color='green' size='2' >"+"√"+"</font>"){
    a=true;
    }else{
    a=false;
    }
    });

    }
    return a;
    }); 
    $("#userpass").blur(function(){
    var password=$("#userpass").val();
    var name=$("#username").val();
    if(password==""||password==null){
    $("#pass").html("<font color='red'>请输入密码! </font>");
    b=false;
    }else if(!/^[a-zA-Z0-9_]{6,16}$/.test(password)){
    $("#pass").html("<font color='red'>输入格式不正确!密码应至少6为数字或字符 </font>");
    b=false;
    }else{
    $.get("LoginAjaxPassword",{"userpass":encodeURI(encodeURI(password)),"username":encodeURI(encodeURI(name))},function(response){
    $("#pass").html(response);
    if(response=="<font color='green' size='2' >"+"√"+"</font>"){
    b=true;
    }
    });

    }
    return b;
    }); 

    $("#login-submit").click(function(){
    var autologin=document.getElementById("autologin").checked;
    if(a&&b){
    //if($("#autologin").attr("checked")==true){
    if(autologin==true){
    //${"#login-user-form"}.attr("action","AutoLogin");
    //$("#login-user-form").submit();
    document.form.action="AutoLogin";
    document.form.submit();
    }else{
    //${"#login-user-form"}.attr("action","Login");
    //$("#login-user-form").submit();
    document.form.action="Login";
    document.form.submit();
    }
    } else{}
    }); 

    });</script>