When moving a string from view to controller, I have encountered an issue. Below is the ajax code I am using:
var formData = $('#spec-wip-form, #platingspec-form').serializeArray();
var platingId = @Model.PlatingId;
var form = JSON.stringify(formData);
$.ajax({
url: "/Specifications/Edit",
type: 'PUT',
data: { form, cleaningProcess, platingId },
success: function () {
onUpdated();
}
});
The current JSON format generated by this code looks like this:
"[{\"name\":\"PlatingId\",\"value\":\"1\"},{\"name\":\"DivisionId\",\"value\":\"79\"}]
I wish for the format to be as follows:
"[{\"PlatingId\":\"1\"},{\"DivisionId\":\"79\"}]
My initial attempt to solve this involved using the following code section:
var formData = $('#spec-wip-form, #platingspec-form').serialize();
However, this resulted in the following output:
formData: PlatingId=1&DivisionId=79&
Any suggestions on how I can achieve the desired JSON format?