我想通过AJAX用一个Label来接收一个值,可是老不出结果??

shelly 2012-05-22 05:39:28
我想通过AJAX用一个Label来接收一个值,可是老不出结果??有没有人知道该怎么写?
using System;
using System.Web;
using May.BLL;

public class GetMsgCount : IHttpHandler {

public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
string MyName = context.Request.QueryString["myName"];
int result = new Relation_MsgManager().GetMsgCount(MyName);//这个函数能查出一个count,如有,则返回1,否则返回-1

if (result > 0)
{
context.Response.Write("1");
}
else
{
context.Response.Write("-1");
}
context.Response.End();

}

public bool IsReusable {
get {
return false;
}
}


}

//AJAX代码:
function ajaxGetMsgCount()
{
var count=$.ajax.responseText;
$.ajax({
url: "ajax/Handler.ashx",
type:"get",
async:true,
cache:false,
timeout:3000,
data:{"myName":$("#<%= txtMyname.ClientID %>").value}, //带了一个参数,txtMyname是个textbox输入框,
success:function(){
$("#<%= lblIsOn.ClientID %>").innerHTML=count;//lblIsOn是一个Label
}

});
}
...全文
49 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
shelly 2012-05-22
  • 打赏
  • 举报
回复
有没有哪位AJAX高手知道啊?

110,533

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧