通过AJAX调用webservice填充下拉列表时出现500内部服务器错误。 [英] 500 internal server error on populating dropdownlist through AJAX call to webservice.
本文介绍了通过AJAX调用webservice填充下拉列表时出现500内部服务器错误。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的网络服务没有被调用。我收到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更改为GET
What I have tried:
I have tried making the method static. changing POST to GET
推荐答案
(窗口).load(function(){
< pre >
(window).load(function () { <pre>
.ajax({
类型:GET,
数据:{},
url:services / VisiTracWS.asmx / GetLocation,
成功:函数(响应){
alert( 1);
var strSection ='< 选项 value = 0 > 选择位置< / option > ';
if(response.d.length> 0){
for(i = 0; i < response.d.length; i ++) {
< span class =code-attribute> < span class =code-attribute> strSection = strSection + '< option value = '+ response.d [i] .LocationID +' > '+ response.d [i] .LocationName +'< / option > 跨度>';
}
}
.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);
},
错误:函数(响应){
alert(response.status ++ response.statusText);
}
});
});
('#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更改为GET
What I have tried:
I have tried making the method static. changing POST to GET
这篇关于通过AJAX调用webservice填充下拉列表时出现500内部服务器错误。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文