本文介绍了通过AJAX调用webservice填充下拉列表时出现500内部服务器错误。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我的网络服务没有被调用。我收到500内部服务器错误。我该怎么办? 这是HTML编码:My webservice is not getting called. I am getting 500 internal server error. what should i do?This is the HTML coding:$(window).load(function () {<pre> $.ajax({ type: "GET", data: {}, url: "services/VisiTracWS.asmx/GetLocation", success: function (response) { alert("1"); var strSection = '<option value="0">Select Location</option>'; if (response.d.length > 0) { for (i = 0; i < response.d.length; i++) { strSection = strSection + '<option value="' + response.d[i].LocationID + '">' + response.d[i].LocationName + '</option>'; } } $('#ddlLocations').html(strSection); }, error: function (response) { alert(response.status + " " + response.statusText); } }); }); 这是网络服务:This is the webservice:<pre>[WebMethod] public static List<Location> GetLocation() { List<Location> lst = new List<Location>(); try { visitrac.Location lc = new visitrac.Location(); DataTable DT = lc.GetDropdown(); lst = (from DataRow dr in DT.Rows select new Location() { LocationID = Convert.ToInt32(dr["LocationID"]), LocationName = Convert.ToString(dr["LocationName"]), }).ToList(); } catch (Exception ex) { // clsException.WriteLog("", "GetLocation", ex.Message); } return lst; } 我的尝试: 我试过将方法设为静态。将POST更改为GETWhat I have tried:I have tried making the method static. changing POST to GET推荐答案 这是网络服务:This is the webservice:<pre>[WebMethod] public static List<Location> GetLocation() { List<Location> lst = new List<Location>(); try { visitrac.Location lc = new visitrac.Location(); DataTable DT = lc.GetDropdown(); lst = (from DataRow dr in DT.Rows select new Location() { LocationID = Convert.ToInt32(dr["LocationID"]), LocationName = Convert.ToString(dr["LocationName"]), }).ToList(); } catch (Exception ex) { // clsException.WriteLog("", "GetLocation", ex.Message); } return lst; } 我的尝试: 我试过将方法设为静态。将POST更改为GETWhat I have tried:I have tried making the method static. changing POST to GET 这篇关于通过AJAX调用webservice填充下拉列表时出现500内部服务器错误。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-19 10:10