I'm having some problems posting multiple parameters to my controller using AJAX. Both parameters end up null and can't figure out why. I'm trying to send the selected values from two drop down lists called "cat_fam_codes" and "cat_codes"
UPDATE: I've added the content type and data types listed below. Same problem: both parameters passed to the controller are null.
In the view:
$('#cat_fam_codes').click(function () {
var categoryData = {
categoryFamilyCodes: $('#cat_fam_codes').val(),
categoryCodes: $('#cat_codes').val()
};
$.ajax({
type: 'POST',
contentType: "application/json; charset=utf-8",
dataType: "json",
url: '/EventReport/GetCCRCodes/',
data: JSON.stringify(categoryData),
success: function (jsonresults) {
if (jsonresults != null) {
$('#ccr_codes').find('option').remove().end();
for (var i = 0; i < jsonresults.length; i++) {
$('#ccr_codes').append('<option value="' + jsonresults[i].CCRCodeId + '">' + jsonresults[i].Description + '</option>');
}
}
},
error: function (xhr, status, error) {
alert('Failed to retrieve CCR Codes for this list. A "' + error + '" response was returned.');
}
});
});
In the controller:
[HttpPost]
public ActionResult GetCCRCodes(string categoryFamilyCodes, string categoryCodes)
{ ... }
Both of the parameters that are passed into the controller a null. Any assisted would e greatly appreciated.
Thanks!