//一般处理程序代码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+"是好朋友"); } });