I am currently working with an Ajax function that serializes data sent from my view into a query string. Here is the code snippet:
UpdateFIConfig: function ($appForm) {
var valid = $appForm.valid();
//if not valid the validate plugin will take care of the errors
if (valid) {
$appForm.serialize();
$.ajax({
url: '/IdentifiConfig/DefaultConfiguration/UpdateFIConfig',
data: $appForm,
dataType: 'application/json',
cache: false,
type: 'POST',
success: function (data) {
if (data.Error) {
cc.jqUtils.openDialog(data.ErrorDescription, 'Error', 'OK', null, null, null);
} else {
window.location.href = '/IdentifiConfig/DefaultConfiguration';
}
}
});
}
},
After serializing the data correctly and verifying it using console.log($appForm)
, the issue arises when trying to retrieve this serialized data in my controller function. The controller function snippet looks like this:
[HttpPost]
public ActionResult UpdateFIConfig(string query)
{
NameValueCollection nvc = HttpUtility.ParseQueryString(query);
System.Diagnostics.Debug.WriteLine(nvc);
}
However, I encounter a null pointer error on the line that attempts to parse the query string. I am unsure why this is happening and would appreciate any guidance or assistance on resolving this issue.