After searching for a few hours here it is. I have an object full of key/value pairs of questionID's and answers. This is how survey.js's onCmplete method generates their question/answers when the survey is completed. The object that I wish to pass to the MVC controller looks like this:
{18: "No", 22: "windows 7", 23: "nc programming", 24: "Server"}
Here is my AJAX POST to my controller action method:
$.ajax({
type: 'POST',
url: '/Assessment/CompleteAssessment',
dataType: 'json',
data: survey.data
})
.done(function() {
alert('Success');
})
.fail(function(xhr) {
alert('Failed.');
});
On the back-end side, my action method looks like this:
[HttpPost]
public ActionResult CompleteAssessment(Dictionary<int, string> assessmentData)
{
return null;
}
I put a breakpoint on the action method and it hits after I make the AJAX POST but I'm not getting any values passed into it. Not sure what to do at this point.
Aucun commentaire:
Enregistrer un commentaire