Jquery ajax 返回值在Label上不显示?求教
jquery 代码:
$(document).ready(function(){
$("#tbUserName").bind("change",function(){
$.ajax({
type:"Get",
url:"/AjaxPages/AjaxCode.aspx" ,
dataType:"text",
data:"userName="+$("#tbUserName").val()+"&flg=username",
// beforesend:function(XMLHttpRequest)
// {
// //$("#showResult").text("checking");
// },
success:function(msg) //这个比较重要
{
alert(msg);
$("#lbCheckUserName").html(msg);
//$("#lbCheckUserName").css("color","red");
//$("#showResult").html(msg);
}
// complete:function(XMLHttpRequest,textstatus)
// {
// //
// },
// error:function()
// {
// //
// }
});
});
AjaxCode代码:
namespace BookShop.AjaxPages
{
public partial class AjaxCode : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string flg = Request.QueryString["flg"].ToString();
if (flg.Equals("username"))
{
CheckUserName();
}
}
protected void CheckUserName()
{
string username = Request.QueryString["userName"].ToString();
Services.UserService us = new BookShop.Services.UserService();
DataTable dt = us.CheckUserName(username);
if (dt.Rows.Count == 0)
{
string s = @"^[0-9a-zA-Z_]{3,}$";
Regex reg = new Regex(s);
Match m = reg.Match(username);
if (m.Success)
{
Response.Write("恭喜您,用户名可以使用!");
}
else
{
Response.Write("用户名不符合规则!");
}
}
else
{
Response.Write("用户名已经被注册!");
}
}
}
}
alert可以弹出对话框,显示有返回值,但是lbCheckUserName(Label)上没显示,请各位老大帮忙看看
------解决方案--------------------