首页 > 学院 > 开发设计 > 正文

c#后台一般处理程序中把变量的值拼成json格式字符串

2019-11-17 01:52:19
字体:
来源:转载
供稿:网友
c#后台一般处理程序中把变量的值拼成json格式字符串
                //一般处理程序代码string login_name = context.Request["login_name"].Trim();                BLLS data = new BLLS();                string select_id = "select use_id from sq_sgxhcom.fru_users where use_name=@p0";                int use_id = Convert.ToInt32(data.Select(select_id, login_name).Tables[0].Rows[0][0]);                string aa = "select use_name,use_realname from sq_sgxhcom.fru_users where use_id=@p0";                string name = data.Select(aa, use_id).Tables[0].Rows[0][0].ToString();                string realname = data.Select(aa, use_id).Tables[0].Rows[0][1].ToString();                string ccc = "select use_name,use_realname from sq_sgxhcom.fru_users where use_id=8";                string name1 = data.Select(ccc).Tables[0].Rows[0][0].ToString();                string realname1 = data.Select(aa, use_id).Tables[0].Rows[0][1].ToString();                string aaa = " [<K>/"name/":/"{0}/",/"realname/":/"{1}/"</K>,<K>/"name/":/"{2}/",/"realname/":/"{3}/"</K>]";//将数据拼成json字符串格式                returnstr = string.Format(aaa, name, realname,name1,realname1).Replace("<K>", "{").Replace("</K>","}");                context.Response.Write(returnstr);
//js代码$.Ajax({         type: "post",         url: "ajax/staff_manag.ashx?type=obtain_count",         data: {             login_type: login_type,             login_name: login_name         },         async: true,         dataType: "json",         success: function fun(json) {             alert("我是"+json[0].name+"和"+json[1].name+"是好朋友");         }     });


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表