Hi
I have below Ajax but it is giving Error 404 not found.
$("#ddlTrainingType").change(function (e) {
$.ajax({
url: "~/TrainingReport/BindTrainingModule/" + $(this).val(),
type: "POST",
contentType: "application/json;charset=UTF-8",
dataType: "json",
success: function (result, status, xhr) {
$("#lstTrainingModule").html(result.d);
},
error: function (xhr, status, error) {
alert("Result: " + status + " " + error + " " + xhr.status + " " + xhr.statusText)
}
});
});
[WebMethod]
public static string BindTrainingModule(string TrainingTypeId)
{
try
{
BALTrainingModule bALTrainingModule = new BALTrainingModule();
List<TrainingModuleMaster> Result = bALTrainingModule.GetRecordDetailsByTypeId(Convert.ToInt32(TrainingTypeId));
if (Result != null)
{
DataTable dt = new DataTable();
dt.Columns.Add("Id", typeof(Int32));
dt.Columns.Add("Name", typeof(string));
foreach (var column in Result)
{
DataRow row = dt.NewRow();
row["Id"] = column.TrainingModuleID;
row["Name"] = column.CourseModule + " / " + column.CourseName;
dt.Rows.Add(row);
}
StringBuilder stringBuilder = new StringBuilder();
//stringBuilder.Append("<option value=\"0\">Select</option>");
foreach (DataRow dr in dt.Rows)
stringBuilder.Append("<option value=\"" + dr["Id"] + "\">" + dr["Name"] + "</option>");
return stringBuilder.ToString();
}
return "0";
}
catch (Exception ex)
{
return "0";
//Utility.SaveErrorLog(ex.Message, System.IO.Path.GetFileName(Request.Path), System.Reflection.MethodBase.GetCurrentMethod().Name, hdfEmpNumber.Value);
//ShowMessage("Oops...", ex.Message, "error");
}
}
Thanks