Hi, I have a MVC application in which i will call a controller using ajax. I have setup everything fine but when i invoke the ajax call, i get Internal Server Error 500 from F12(Google Chrome). I double checked my codes(javascript and C#) and seem nothing wrong. Below are my codes:
$.ajax({
type: "POST",
url: "/PrawnFarm/UpdatePrawnFarmDetail",
data: {
'pH': $ph,
'salPerc': $salPerc,
'salDeg': $salDeg,
'doMG': $doMG,
'doDeg': $doDeg,
'water': $water,
'rain': $rain,
'pondId': $pondId,
},
success: function (data) {
},
fail: function (jqXHR, textStatus, errorThrown) {
}
});
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult UpdatePrawnFarmDetail(decimal pH, decimal salPerc, decimal salDeg, decimal doMG, decimal doDeg, int water, int rain, long pondId)
{
using (DB_TestEntities db = new DB_TestEntities())
{
PrawnFarmDetail prawnFarmDetail = new PrawnFarmDetail();
prawnFarmDetail.PH = pH;
prawnFarmDetail.SAL_Percentage = salPerc;
prawnFarmDetail.SAL_Degree = salDeg;
prawnFarmDetail.DO_Volume = doMG;
prawnFarmDetail.DO_Degree = doDeg;
prawnFarmDetail.Water_Volume = water;
prawnFarmDetail.RAIN = rain;
prawnFarmDetail.PondId = pondId;
db.SaveChanges();
}
return View();
}
What I have tried:
1. Debug the javascript and all values are captured correctly.