在本地测试一切正常但,发布到服务器就报错
jquery代码:
$("#username").formValidator({onshow:"请输入用户名",onfocus:"3-16位,英文开头,英文、数字、下划线组成",oncorrect:"恭喜此用户可注册!"}).regexValidator({regexp:"^[a-zA-Z]{1}[a-zA-Z0-9\\_]{2,15}$",onerror:"用户名格式不正确,3-16位,英文开头,英文、数字、下划线组成"})
.ajaxValidator({
type : "get",
url : "ajaxValidator.ashx",
datatype : "json",
success : function(json){
if( json.exists == "1" )
{
return true;
}
else
{
return false;
}
},
buttons: $("#button"),
error: function(){alert("服务器没有返回数据,可能服务器忙,请重试");},
onerror : "该用户名不可用,请更换用户名",
onwait : "正在对用户名进行合法性校验,请稍候..."
});后台代码:
public void ProcessRequest(HttpContext context)
{
string ReturnData = null;
context.Response.ContentType = "text/plain";
if(context.Request.QueryString["username"] != null)
{
string username = context.Request.QueryString["username"].ToString();
ReturnData = ExistsByUserName(username);
}
context.Response.Write(ReturnData);
}
public string ExistsByUserName(string userName)
{
int id = BLL.Sys_User_BLL.GetUserID(userName);
if (id > 0) return "{exists:\"0\"}";
else return "{exists:\"1\"}";
}
jquery代码:
$("#username").formValidator({onshow:"请输入用户名",onfocus:"3-16位,英文开头,英文、数字、下划线组成",oncorrect:"恭喜此用户可注册!"}).regexValidator({regexp:"^[a-zA-Z]{1}[a-zA-Z0-9\\_]{2,15}$",onerror:"用户名格式不正确,3-16位,英文开头,英文、数字、下划线组成"})
.ajaxValidator({
type : "get",
url : "ajaxValidator.ashx",
datatype : "json",
success : function(json){
if( json.exists == "1" )
{
return true;
}
else
{
return false;
}
},
buttons: $("#button"),
error: function(){alert("服务器没有返回数据,可能服务器忙,请重试");},
onerror : "该用户名不可用,请更换用户名",
onwait : "正在对用户名进行合法性校验,请稍候..."
});后台代码:
public void ProcessRequest(HttpContext context)
{
string ReturnData = null;
context.Response.ContentType = "text/plain";
if(context.Request.QueryString["username"] != null)
{
string username = context.Request.QueryString["username"].ToString();
ReturnData = ExistsByUserName(username);
}
context.Response.Write(ReturnData);
}
public string ExistsByUserName(string userName)
{
int id = BLL.Sys_User_BLL.GetUserID(userName);
if (id > 0) return "{exists:\"0\"}";
else return "{exists:\"1\"}";
}
url : "ajaxValidator.ashx",
datatype : "json",
async: true,
加红字看看
这个:" error: function(){alert("服务器没有返回数据,可能服务器忙,请重试");},
"