I have simple class
public class CaseField
{
public string XPath { get; set; }
public string NewValue { get; set; }
}
And controller
public string SaveCaseData(string authority,
string shopNo,
string caseNo,
CaseField[] caseFields)
{
return new Service().SaveCaseData(authority,shopNo,caseNo,caseFields.ToList());
}
And jQuery ajax request
var editableFieldsArray = [];
$('.editable').each(
function () {
var caseField = {};
caseField.NewValue = $(this).attr("value");
caseField.XPath = $(this).attr("xpath");
editableFieldsArray.push(caseField);
}
);
var params = { authority: authority, shopNo: shopNum, caseNo: caseNum, caseFields: editableFieldsArray };
$.ajax({
url: $('.CaseDataView').data('url'),
datatype: 'json',
data: params,
success: function (result) {
isDataChanged = false;
if (showOperationResult) {
if (result == 'Successful') {
jAlert('Case data saved succesfully!', '', 'BigInfoIcon');
} else if (result == 'Failed') {
jAlert('Failed to save case data!', '', 'BigInfoIcon');
}
}
HideChangeProcess();
}
});
First 3 params i receive. But with array i have problem - in my browser i look at editableFieldsArray and i have array with correct data, but in controller i have array with null values
EDIT
Before ajax call in chrome i have this structure of params
params
Object
authority: "localhost"
caseFields: Array[3]
0: Object
NewValue: "Thurid Waagstein Madsen"
XPath: "Case/SalesInfo/Customers/CustomerContactInfo/Name"
__proto__: Object
1: Object
NewValue: "Holger Danskes Vej 79"
XPath: "Case/SalesInfo/Customers/CustomerContactInfo/Address"
__proto__: Object
2: Object
NewValue: "Frederiksberg"
XPath: "Case/SalesInfo/Customers/CustomerContactInfo/City"
__proto__: Object
length: 3
__proto__: Array[0]
caseNo: "06659"
shopNo: "N100250"
__proto__: Object
In firebug:
Where is mistake ?