+ -
当前位置:首页 → 问答吧 → 大家看我做的JQ+AJAX哪里有错误

大家看我做的JQ+AJAX哪里有错误

时间:2009-06-27

来源:互联网

<script type="text/javascript">

$(document).ready

(
function()
{
    $("#form").submit
    (
       function()
        {
        login();
        return false;
        }
    );
}
);
function login()

{
var qq = $("#qq").val();
var password = $("#password").val();
if (qq == "")
{
    $("#confirm").text("请输入登录用户名");
    $("qq").focus();
    return false;
}
if(password == "")
{
    $("#confirm").text("请输入登录密码");
    $("#password").focus();
    return false;
}
$.ajax({
    
    type: "get",
    url: "index.php?c=adviser&a=ajax",
    data: "id=" + qq + "&p=" + password,
    beforeSend: function(){
    $("confirm").text("登录中,请稍候");
    },
    success: function(msg){
    if(msg == "success"){
        $("#confirm").text("登录成功");
    }else {
        $("#confirm").("没有此用户或者密码不正确!");
    }
    }
});
}
</script>

<form action="{{url controller=adviser action=check}}" method="post"  style="display:{{$islogout}}" name="form" id="form" >
        <div class="maincenter1">顾问帐号:<input type="text" name="qq"  id="qq" style=" border:#FFCC00 1px solid;background-color:#000000; width:200px; color:#FFFFFF;"> </div>
        <div class="maincenter1">登录密码:<input type="password" name="password" id="password" style=" border:#FFCC00 1px solid;background-color:#000000;width:200px; color:#FFFFFF;"></div>
            <div class="maincenter2"><input type="submit"   value="登录" id="submit" name="submit" style="border:#000000 1px solid; height:30px; width:72px; color:#4d4d4d;background:url(images/denglu.jpg) no-repeat; line-height:30px; line-height:30px; overflow:hidden;"><img src="{{$image_path}}/zhuce.jpg" />
<!--<input  value="注册" style="border:#000000 1px solid; height:30px; width:72px;background:url(images/denglu.jpg) no-repeat; line-height:30px; color:#4d4d4d; line-height:30px; overflow:hidden;padding-left:20px;">-->
    <a href="{{url controller=adviser action=register}}" style="background:url(images/denglu.jpg);background-repeat:no-repeat; width:72px; height:30px;color:#4d4d4d;padding-left:20px; padding-top:7px;">注册</a>        
            
            </div>
                 </form>

作者: 411439140   发布时间: 2009-06-27

首先是dataType是什么,text么,设置一下error参数把你的出错信息显示出来

其次是登录不应该用GET,因为密码是以URL明文发送的,这样很容易被拦截和攻击,是对用户的不负责

作者: keakon   发布时间: 2009-06-27

type:'post'

作者: quweiie   发布时间: 2009-06-29

相关阅读 更多