Copy Code code as follows:
Background
[HttpPost]
Public Jsonresult Checkstock (ienumerable<pvidscount> pvids)
{
}
public class Pvidscount
{
public int PvId {set; get;}
public int count {set;
}
Front desk
$ (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",////Complex object transfer value with post,
Data:JSON.stringify ({pvids:productidcounntlist}),//son.stringify---must used to serialize
DataType: "JSON",
ContentType: ' Application/json; Charset=utf-8 ',//must
Error:function () {
Alert ("1");
},
Success:function (data) {
}