我想通过AJAX用一个Label来接收一个值,可是老不出结果??
我想通过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
}
});
}