On click of an anchor tag the action of my controller is hit. there is a parameter that is passed in query string . I am converting a List to serialized json sting using the below code.
public ActionResult EmployeeVote(string regionID)
{
var nomineeList = NomineeModel.GetNomineeByRegionID(Convert.ToInt16(regionID));
ViewBag.NomineeList = JsonConvert.SerializeObject(nomineeList,Formatting.None);
return View(ViewBag);
}
Ths json string I think there is some issue with the way the string is made.
[{"Id":0,"EmpId":1,"FirstName":"First Last","Email":"[email protected]","Description":null,"RegionID":0}]
On client side. But model list is giving error while deserializing it.
$(function () {
var modelList = JSON.parse('@ViewBag.NomineeList');
$(modelList).each((function () { //some logic});
});
I want to perform an each loop to iterate over the model list to create some dynamic element. Any help ??
[{"Id":0,"EmpId":1,"FirstName":"First Last","Email":"[email protected]","Description":null,"RegionID":0}]is not valid JSON.