JQuery 1.3.2联动获取部门
2018-06-18 04:55:56来源:未知 阅读 ()
| Sql | |
$(document).ready(function(){
$(".dept").bind("click", function () {
var self = this;
var open = $(self).attr("open");
if (open=="false") {
$(self).attr("open", "true");
}
$.ajax({
type: "post",
data: {
data: JSON.stringify( {Description:$(this).attr("desc")})
},
url: "GetDeptName.ashx",
success: function (data) {
if (data != null || data !== "") {
if (open=="false") {
$(self).children(".dept").remove();
return false;
}
var entitys = JSON.parse(data);
$.each(entitys.prod, function (index, element) {
var ul = $("<ul></ul>");
var li = "<li><span class='dept' open='false' desc='" + element.Description + "'>" + element.Name + "</span></li>";
ul.append(li);
$(self).after(ul);
});
}
}
});
});
});
c#代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Script.Serialization;
namespace Maticsoft.Web.Product
{
/// <summary>
/// GetDeptName 的摘要说明
/// </summary>
public class GetDeptName : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
JavaScriptSerializer jss = new JavaScriptSerializer();
string entity = context.Request["data"];
Model.Products model= jss.Deserialize<Model.Products>(entity);
List<Model.Products> prod = new BLL.Products().GetModelList(string.Format(" Catagory={0}",model.Description));
if (prod!=null&&prod.Count()>0)
{
context.Response.Write(jss.Serialize(new {prod= prod}));
return;
}
context.Response.Write(string.Empty);
}
public bool IsReusable
{
get
{
return false;
}
}
}
}
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
上一篇:C#访问修饰符
下一篇:修改datatable列
- jquery获取select选中的文本值 2020-01-02
- jQuery - 拦截所有Ajax请求(统一处理超时、返回结果、错误 2019-11-29
- 继上篇-jquery ajax提交 本篇用ajax提交的数据去数据库查询 2019-11-28
- Sping MVC不使用任何注解处理(jQuery)Ajax请求(基于XML配 2019-11-02
- ajax+JQuery实现类似百度智能搜索框 2019-08-26
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash
