CopyCode The Code is as follows: // The background
[Httppost]
Public jsonresult checkstock (ienumerable <pvidscount> pvids)
{
}
Public class pvidscount
{
Public int PVID {set; get ;}
Public int count {set; get ;}
}
// Front-end
$ (Document). Ready (function (){
$ ('# Checkout'). Click (function ()
{
VaR productidcounntlist = [];
VaR allpvid = $ (". productvariantidall ");
$. Each (allpvid, function (index, data ){
VaR productidcounnt = {PVID: Data. getattribute ("data-ID"), Count: Data. getattribute ("data-count ")};
Productidcounntlist. Push (productidcounnt );
});
$. Ajax ({
URL: "@ URL. Action (" checkstock ")",
Type: "Post", // use post to pass values to complex objects,
Data: JSON. stringify ({pvids: productidcounntlist}), // son. stringify --- Must for serialization
Datatype: "JSON ",
Contenttype: 'application/JSON; charset = UTF-8 ', // must
Error: function (){
Alert ("1 ");
},
Success: function (data ){
}