I would like get all data into an object with request ajax.
This data are get into my controller with a function.
In the headers of my data I have this information:
I have 4 objects allPly create but all data(gramme,lotion and others) equals null or zero.
But the data comment and OtherData it’s ok, this works.
Thanks for your help
My Request:
var params={};
var allStep21 ={allData..}
$.extend(params,allStep21);
$.ajax({
type: "POST",
url: "Request",
data: params,
});
In the headers html:
allPly[0][Gramme]:10
allPly[0][Toto]:White
allPly[0][Test]:None
allPly[0][Lotion]:1
allPly[1][Grammage]:11
allPly[1][Toto]:White
allPly[1][Test]:Fine
allPly[1][Lotion]:0
OtherData : 585
Comment: all it's ok
In my controller:
[HttpPost]
public ActionResult Request(AllStep21 allStep21)
{
}
In my model:
public class AllStep21
{
public String OtherData { get; set; }
public String Comment { get; set; }
public List<allPly> allPly { get; set; }
}
public class allPly
{
public int Gramme { get; set; }
public String Toto { get; set; }
public String Test { get; set; }
public int Lotion { get; set; }
}
You could use a JSON request which allows you to send arbitrary complex objects to your controller actions:
The
JSON.stringifymethod shown here is natively built into all modern browsers. But if you need to support legacy browsers you need to include the json2.js script.