Hi,
I have a webform where I am performing ajax call using jquery.
My code executes webmethod successfully and fills the data into a list item and returning that list. But on ajax success call it throughs the below error HTTP/1.1 500 Internal Server Error 37ms.
I google it out but unable to figure it out.
Please help me understand and resolve this.
Any suggestions will be appriciated. Below is my code
$.ajax({
type: "POST",
url: "ManPowerEntry.aspx/getProjectNames",
dataType: "json",
contentType: "application/json",
success: function (result, status) {
alert("result");
$("#ddlProject").empty();
$("#ddlProject").append($("<option value='0'> --Select Project--</option>"));
$.each(result.d, function (key, value) {
$("#ddlProject").append($("<option></option>").val(value.projectCode).html(value.projectName));
});
$('.autofilter').fSelect();
},
error: function ajaxError(result) {
alert(result.status + ' : ' + result.statusText);
}
});
[WebMethod]
public static List<ProjectManPower> getProjectNames()
{
string query = "select project_code, project_name from ProjectMaster";
DataTable dt = SqlConn.SqlExce.fillDataTableRet(query);
List<ProjectManPower> lsts = new List<ProjectManPower>();
foreach (DataRow dr in dt.Rows)
{
lsts.Add(new ProjectManPower
{
projectCode = dr["project_code"].ToString(),
projectName = dr["project_name"].ToString()
});
}
return lsts;
}