求ajax高手帮忙看下,不知道哪儿错了。有数据传递,但是总是出的是没有数据??

shelly 2012-05-24 11:16:04
这是我的handler:我试过了,GetUnreadMsgCnt(int receiveId)查出了数据。
public class GetMsgCount : IHttpHandler {

public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
int receiveId = Convert.ToInt32(context.Request.QueryString["receiveId"]);
int result = new MessageManager().GetUnreadMsgCnt(receiveId);

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

这是我的js获取数据:
var count=0;
function ajaxGetMsgCount()
{
$.ajax({
url: "ajax/GetMsgCount.ashx",
type:"GET",
data:{"receiveId":$(".txtMyId").val()},
radomID:Math.random(),
success:function(){

if(count.responseText=="1")
{
alert("有消息");
}
else
{
alert("没有消息");//总是执行这一件,我设置了断点,测试是(result > 0),但是老执行到了这儿
}
}

});

有没有哪位高手知道错在哪了啊??求帮忙。
}
...全文
106 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
shelly 2012-05-24
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 的回复:]

var count=0;
function ajaxGetMsgCount()
{
$.ajax({
url: "ajax/GetMsgCount.ashx",
type:"GET",
data:{"receiveId":$(".txtMyId").val()},
radomID:Math.random(),
success:function(dat……
[/Quote]
谢谢谢谢,果然有用,谢谢。
shelly 2012-05-24
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 的回复:]

var count=0;
function ajaxGetMsgCount()
{
$.ajax({
url: "ajax/GetMsgCount.ashx",
type:"GET",
data:{"receiveId":$(".txtMyId").val()},
radomID:Math.random(),
success:function(dat……
[/Quote]
谢谢,谢谢,可以接收到数据了。
pwc1990 2012-05-24
  • 打赏
  • 举报
回复
$.ajax({
type: "post",

url: "MapValue.aspx/isFull", //页面和方法

data: "{'rest':'"+value+"'}", //方法的参数
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(data) {
//返回的数据用data.d获取内容
$("#Tname").val(data.d[0]);


},
error: function(err) {
alert("出错了!");
}
});
newxdlysk 2012-05-24
  • 打赏
  • 举报
回复
var count=0;
function ajaxGetMsgCount()
{
$.ajax({
url: "ajax/GetMsgCount.ashx",
type:"GET",
data:{"receiveId":$(".txtMyId").val()},
radomID:Math.random(),
success:function(data){

if(data=="1")
{
alert("有消息");
}
else
{
alert("没有消息");//总是执行这一件,我设置了断点,测试是(result > 0),但是老执行到了这儿
}
}

});

有没有哪位高手知道错在哪了啊??求帮忙。
}
shelly 2012-05-24
  • 打赏
  • 举报
回复
刚改了下语句,发现count.responseText不等于1也不等于-1,不知道是不是写错了!!唉,不懂这个格式怎么写?

110,539

社区成员

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

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

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