I have the following ajax call
$.ajax({
type: "POST",
url: url,
dataType: "json",
data: { occupants: occupants },
success: function (data) {
$("#summaryContent").html(data);
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
console.log("Status: " + textStatus);
console.log("Error: " + errorThrown);
}
});
And a controller that looks like this
[HttpPost]
public PartialViewResult Verification(List<OccupantDto> occupants)
{
//do stuff
return PartialView();
}
And I'm getting this error in my ajax call
Error: SyntaxError: JSON.parse Error: Invalid character at position:5
I tried removing dataType: "json" from my ajax call, that removes the error, and it renders my partial view, however, in my controller, occupants is an empty list. Adding dataType: "json" populates occupants in my controller, but throws me an error.