I have a stringified JSON object that appears properly in an alert, appears properly in the post section in the browser debugger, but in the controller it appears as null. I'm not sure how it is losing the information.
Here is the JS code:
var assessmentStatus = [];
$("select.assessmentSelect").each(function () {
assessmentStatus.push({
assessmentname: $(this).attr("id"),
assessmentstatus: $(this).val()
});
});
alert(JSON.stringify(assessmentStatus));
$.ajax({
url: '@Url.Action("testAS")',
type: "POST",
contentType: 'application/json',
data: JSON.stringify({
AS: assessmentStatus,
AS2: assessmentStatus
})
});
this is what is appearing in the alert:
[{"assessmentname":"testassessment","assessmentstatus":"Design"},{"assessmentname":"DepressionUpload","assessmentstatus":"Design"}]
this is what is appearing in the post:
[Object { assessmentname="testassessment", assessmentstatus="Design"}, Object { assessmentname="DepressionUpload", assessmentstatus="Design"}]
my controller looks like this:
public ActionResult testAS (string[] AS, string AS2)
string[] AS returns [0]null [1]null
string AS2 just returns null.
Why is it not getting stringified when being sent to the controller?