Asp.net 2.0 jQuery取数据失败

kong佳 2012-11-13 08:57:01
服务器端:
using System;
using System.Collections;
using System.Web;

namespace SiteServer.CMS.BackgroundPages.UserAjax
{
public class UserAjax : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
var data = new Hashtable();
if (!StringUtils.IsNullorEmpty(UserFactory.Instance.CurrentUserName))
{
IUserInfo userInfo = UserFactory.Instance.GetUserInfo(UserFactory.Instance.CurrentUserName);
//data["userName"] = UserFactory.Instance.CurrentUserName;
//data["email"] = userInfo.Email;
//data["company"] = userInfo.Mobile;
data.Add("userName",userInfo.UserName);
data.Add("email",userInfo.Email);

}
//var jss = new JavaScriptSerializer();
//var json = jss.Serialize(data);

context.Response.ContentType = "text/javascript";
context.Response.Write(data);
}

public bool IsReusable
{
get { return false; }
}
}
}


using System;
using System.Collections;
using System.Web;
//using System.Web.Script.Serialization;
using BaiRong.Core;
using UserCenter.Core;
using UserCenter.Model;

namespace SiteServer.CMS.BackgroundPages.UserAjax
{
public class UserAjax : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
var data = new Hashtable();
if (!StringUtils.IsNullorEmpty(UserFactory.Instance.CurrentUserName))
{
IUserInfo userInfo = UserFactory.Instance.GetUserInfo(UserFactory.Instance.CurrentUserName);
//data["userName"] = UserFactory.Instance.CurrentUserName;
//data["email"] = userInfo.Email;
//data["company"] = userInfo.Mobile;
data.Add("userName",userInfo.UserName);
data.Add("email",userInfo.Email);

}
//var jss = new JavaScriptSerializer();
//var json = jss.Serialize(data);

context.Response.ContentType = "text/javascript";
context.Response.Write(data);
}

public bool IsReusable
{
get { return false; }
}
}
}


但总是无法提取数据,请问是什么原因
...全文
106 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhujiazhi 2012-11-14
  • 打赏
  • 举报
回复
context.Response.ContentType = "application/json"; 1、断点,测试能否进入后台,以及后台代码执行是否正确 2、用firebu检查结果,查看请求地址,以及返回内容
myhope88 2012-11-14
  • 打赏
  • 举报
回复
直接预览获取数据的页面看一下,有无正常
kong佳 2012-11-13
  • 打赏
  • 举报
回复
我就是测试不出来才要你们帮忙啊
md5e 2012-11-13
  • 打赏
  • 举报
回复
自己把调取的页页及参数在浏览器上运行上次,看看是否有结果出来

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

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