I am looking to send a map (dictionary) to the MVC controller along with a string parameter.
var reportName= 'ReportName';
var FilterValues = new Map([
[0, "value1"],
[1, "value2"],
[2, "value3"],
]);
var model = { reportName: reportName, FilterValues: JSON.parse(FilterValues) };
$.ajax({
url: '/Reports/ExportReport/',
type: 'POST',
contentType: "application/json",
data: model,
success: function(){
alert('success');
},
error: function(){
alert('failure');
}
});
public void ExportReport(string reportName, Dictionary<int, string> FilterValues)
{
I attempted this approach using an Object instead of a map. Although it returned success, it did not hit the controller.
let FilterValues = {
1: "value1",
2: "value2",
3: "value3",
};
var report = 'test';
// var data = ('#DesignationReport').DataTable().$('input,select,textarea').serialize();
var model = { reportName: report, FilterValues: FilterValues };
This marks my latest attempt.