带有asp.net的JQuery $ .get()在服务器上出现503错误

时间:2012-11-08 05:26:29

标签: jquery asp.net ajax

我正在开发一个基本上是注册页面的应用程序。我想通过检查数据库中的现有电子邮件ID来停止重复注册。我使用JQuery $ .get()方法在后台查询页面,然后获取现有或不存在的电子邮件的结果。该页面在本地运行完美,但在线,当输入重复的电子邮件ID时,它将返回"503 Service Unavailable"

jQuery方法如下:

<script type="text/javascript">
$(document).ready(function () {
    $("#ctl00_ContentPlaceHolder1_tbEmail").change(function () {
        var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
        var emailaddressVal = $("#ctl00_ContentPlaceHolder1_tbEmail").val()
        if(!emailReg.test(emailaddressVal)) {
            $("#msgbox").html('Invalid Email ID');
        return;
    }
        $("#ctl00_ContentPlaceHolder1_hidYorN").val("")
        $("#msgbox").removeClass().addClass('messagebox').text('Checking...').fadeIn("slow");
        $.get("scripts/email_availibility.aspx", { user_name: $(this).val() }, function (data) {
            if (data == 'no') 
            {
                $("#msgbox").fadeTo(200, 0.1, function () 
                {
                    $(this).html('This mail id is already registered!').addClass('messageboxerror').fadeTo(900, 1);
                    $("#ctl00_ContentPlaceHolder1_hidYorN").val("N");
                });
            }
            else {
                $("#msgbox").fadeTo(200, 0.1, function ()  
                {
                    $(this).html('You are welcome to register!').addClass('messageboxok').fadeTo(900, 1);
                    $("#ctl00_ContentPlaceHolder1_hidYorN").val("Y");
                });
            }
        });
    });
});
</script>

我的aspx页面代码(email_availibility.aspx):

string con = ConfigurationManager.ConnectionStrings["myDB"].ConnectionString.ToString();
protected void Page_Load(object sender, EventArgs e)
{
    string data = "no";
    OleDbConnection conn = new OleDbConnection(con);
    string user_name = Request.QueryString["user_name"];
    string strQury = "Select [EmailID] from [RegisterTable] where [EmailID]='" + user_name + "'";
    OleDbCommand cmds = new OleDbCommand(strQury, conn);
    OleDbDataReader dr;
    if (conn.State == ConnectionState.Closed)
        conn.Open();
    dr = cmds.ExecuteReader();
    if (dr.HasRows)
    {
        data = "no";
    }
    else
    {
        data = "yes";
    }
    if (conn.State == ConnectionState.Open)
        conn.Close();
   Response.Write(data);
}

我不太习惯JQuery,刚刚开始使用它,所以请简单回答

0 个答案:

没有答案