I have a form with a textarea and when trying to send the information, I am using JSON.stringify, I get errors. Here is the code:
$.ajax({
type: "POST",
dataType: "json",
data: JSON.stringify({
reportid: data["reportid"], //Guid
assessmentId: data["assessmentId"], //Guid
title: data["title"], //string
body: data["body"], //string
section: data["section"], //string
reportsection: data["reportSection"] //string
}),
url: "/Assessments/ModifyAssessmentTemplateText",
success: function (data) {
lastModified = data["LastModified"];
updateLastModified(lastModified);
alert(data);
}
});
My controller method was set up as follows:
[POST("ModifyAssessmentTemplateText")]
[AjaxOnly]
public JsonResult ModifyAssessmentTemplateText(Guid reportid, Guid assessmentid, string title, string body, string section, string reportSection)
{
//...
}
I get a 500 server error.
I know that when I tried testing, and had only one parameter, reportid, and had my method accept a string, it worked. But when I set it to Guid I get the 500 error. Is there a way I should be parsing the JSON server side?
EDIT:
Note: when I don't use data, and I do url: "/Assessments/ModifyAssessmentTemplateText?reportid=" + reportid
it works with no problem.