In console showed me an error that parameters dictionary contains a null entry fo parameter wantedids
,
So I wanted to pass checked boxes to my controller using array, so only admin can check all boxes of tips for specific user, admin have more than 5 users, In my console i succesfully pass an checked elements but it only showed me an error after that Internal server error
. How can I pass that so I can update my database with checked boxes, can someone help.
<input type="checkbox" class="cktips" idtips="@item.idtips
checked="@(item.iduser == ViewBag.iduser ? true : false)"/>
.js
var wantedids = [];
$("#btnClick").click(function () {
$(".cktips").each(function () {
$(this).prop('checked', true);
ids.push($(this).val());
});
$.ajax({
url: UrlSettingsDocument.Tips,
data: { ids: ids},
type: "POST",
success: function () {
alert('successs');
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
}
})
})
Here is my Controller.cs
public JsonResult Statics(bool ids,int iduser,int idtips)
{
try
{
if (ids)
{
statics = new statics ();
st.idtips= idtips;
Database.statics .Add(st);
Database.SaveChanges();
}
else if (!ids)
{
var stdelete= Database.statics.Where(a => a.iduser == iduser &&
a.idtips== idtips).FirstOrDefault();
Database.statics.Remove(stdelete);
Database.SaveChanges();
}
if (Request.IsAjaxRequest())
{
return Json(true, JsonRequestBehavior.AllowGet);
}
else
{
return Json(true, JsonRequestBehavior.AllowGet);
}
}
catch (Exception ex)
{
Logger.Error("Error: {0}", ex.ToString());
return null;
}
question from:
https://stackoverflow.com/questions/65853939/the-parameters-dictionary-contains-a-null-entry-for-parameter-wantedids-of-non 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…