5
Witam Mam wywołanie ajax:Server odpowiedział ze statusem 500 (wewnętrzny błąd serwera) przy użyciu Ajax
$.ajax({
url: "/Orders/CheckIfExists",
type: "GET",
contentType: "application/json; charset=utf-8",
data: {
catalogNumber: viewModel.catalogNumber,
quantity: viewModel.quantity
},
error: function (data) {
alert("wystąpił nieokreślony błąd " + data);
},
success: function (data) {
if(data.ok)
{
alert(data.quantity)
}
}
})
});
i oto metoda kontroler:
public JsonResult CheckIfExists(string catalogNumber, int quantity)
{
List<Expression<Func<DeviceInstance, bool>>> where = new List<Expression<Func<DeviceInstance, bool>>>();
where.Add(w=>w.DeviceUsage.UserId==1);
where.Add(w => w.Project == null);
where.Add(w => w.Device.CatalogNo == catalogNumber);
var result = unitOfWork.deviceInstanceRepository.Get(where)
.GroupBy(w => new
{
DeviceId = w.DeviceId,
CatalogName = w.Device.CatalogNo,
})
.Select(s => new
{
Quantity = s.Sum(x => x.Quantity),
}).First();
if (result.Quantity >= quantity)
{
return Json(new { ok = true, quantity = result.Quantity});
}
return Json(new { ok = false });
}
ale zawsze jestem coraz Wewnętrzny błąd 500. Dane są odbierane według metody i wszystkie obliczenia są w porządku. Komponuję return JSON jak w przykładzie. Gdzie popełniłem błąd?
Dzięki człowiek !!! ... Kocham Cię –