说明: ArrayList 中 存为对象CollegeDepartInfo 其属性为:stirng CollegeDepartTitle 和 int CollegeDepartId 在javascript中 ddlDepart.options[ddlDepart.length]=new Option(n.CollegeDepartTitle,n.CollegeDepartId); Option的参数就是依据他们的。 最后重要的是: 类上方添加的 [ScriptService] 必须添加,否则ajax无法调用WebService
jquery代码部分:
CollegeDepartWebServices.asmx.cs部分:
[WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [ScriptService] public class CollegeDepartWebServices : System.Web.Services.WebService { public CollegeDepartWebServices() { //如果使用设计的组件,请取消注释以下行 //InitializeComponent(); } [WebMethod] [System.Xml.Serialization.XmlInclude(typeof(CollegeDepartInfo))] public ArrayList GetCollegeDepart(string strDepartId) { CollegeDepartBL.FlushCollegeDepartCache(); if (string.IsNullOrEmpty(strDepartId)) return null; ArrayList myList = CollegeDepartBL.GetCollegeDepartListByCollegeID(int.Parse(strDepartId)); return myList; } }
希望本文所述对大家的jquery程序设计有所帮助。
Copyright © 2019- kqyc.cn 版权所有 赣ICP备2024042808号-2
违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务