createHttpReques(); var id=obc.options[obc.selectedIndex].value; xmlHttp.open("GET","WebService1.asmx/GetCity?id="+id,true); xmlHttp.onreadystatechange = function() { if (xmlHttp.readyState == 4 && xmlHttp.status == 200) { var obj = xmlHttp.responseXML; var cc = document.getElementById("DropDownList2");
ClearItem(cc);
var dd = document.getElementById("DropDownList3");
ClearItem(dd); var ary = obj.getElementsByTagName("City"); alert(ary.length); for (i = 0; i < ary.length; i++) { var optio = document.createElement("option"); optio.text = ary[i].getElementsByTagName("CityName")[0].firstChild.nodeValue; optio.value = ary[i].getElementsByTagName("CityID")[0].firstChild.nodeValue; cc.options.add(optio); } } } xmlHttp.send(null); }
------解决方案-------------------- webservice的CS页面的代码有没有加上[ScriptService]标签啊,如果没有的话不能被JS调用的,楼主检查一下
/// <summary> /// 说明 /// </summary> [WebService(Namespace = "SysTest/MyService.asmx")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [ScriptService] public class MyService: System.Web.Services.WebService { .......