When I am trying to run this code in .NET framework, I get a status code 500, but I don’t know why…
This is the back end:
public ActionResult getvisit(int id)
{
var query = __db.Visits
.Where(v => v.fkDoctor == id && v.fkPatient == null)
.Select(v => new {v.Id, v.sDate})
.ToList();
List<object> visits = new List<object>();
foreach (var item in query)
{
var sdatetime = new PersianDateTime(item.sDate);
visits.Add(new {item.Id, sdatetime.Date, sdatetime.TimeOfDay});
}
var result = Json(visits, JsonRequestBehavior.AllowGet);
return result;
}
Front end:
docSpan.on("change", function () {
const id = docSpan.val();
visitSpan.empty();
visitSpan.append(
"<option value=''>انتخاب کنید</option>"
)
$.post("/Home/getvisit", { id: id })
.done(function (res) {
console.log(res);
for (let item of res) {
console.log(item);
visitSpan.append(
`<option value=${item.id}>${item.sdate} || ${item.stime}</option>`
);
}
})
.fail(function () {
})
.always(function () {
});
})
I don’t have any idea why this happens.
New contributor
anathan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1