火速求助!!菜鸟Ajax问题

hai6673000 2013-08-14 01:05:38
一个aspx页面,一个ashx页面,,怎么把ashx文件中的context.Response.Write("OK");传到前台的label显示啊?谢谢

这个是ashx 里面的代码
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
string name = context.Request["name"];
int names=int.Parse(name);
string user_id = context.Request["user_id"];
int use = int.Parse(user_id);




JavaScriptSerializer jss = new JavaScriptSerializer();
//等级一
if (mod.user_score >= 100 && mod.user_score <= 200)
{
if (moo.login_score > names && names < 10)
{
string json = "OK";
context.Response.Write(json); 需要把这个到前台显示!!


}
else {
string json = "OK";
context.Response.Write(json);
}


}


前台代码 主要是这里不晓得改 帮忙改改吧
$(function () {
$("#txtContents").keyup(function () { //键盘弹起的时候发生
if ($("#txtContents").val().length > 0) { //文本框不为空时发生
$("#ulContent").attr("style", "display:block");
$.getJSON("Handler2.ashx", { "name": $("#txtContents").val(), "user_id": $("#TextBox1").val() }, function (data) {
$("#ulContent").empty(); //清空ul
$.each(data, function (index, emp) {
$("#ulContent").append("<li>" + emp.question_title + "</li>");



});
});
}

});
...全文
140 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
jonny0220 2013-08-14
  • 打赏
  • 举报
回复
$.ajax({ type: "post", dataType: "text", url: 'Handler2.ashx', data: { "name": $("#txtContents").val(), "user_id": $("#TextBox1").val() }, success: function (msg) { var htmls = "<li>" + msg + "</li>"; $("#ulContent").append(htmls); } });
Go 旅城通票 2013-08-14
  • 打赏
  • 举报
回复
后台都不对,就返回了一个OK字符串。。 楼主先想好后台要返回什么数据先
tony4geek 2013-08-14
  • 打赏
  • 举报
回复
你后台要设置好类型 josn类型, 数据格式,等等。

52,797

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Ajax
社区管理员
  • Ajax
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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