【发布时间】:2016-10-07 04:56:14
【问题描述】:
我碰壁了,simplecart如何POST数据?我尝试了一堆不同的数据类型,但我得到的都是空的。
用于 simplecart 设置的 JS:
<script>
simpleCart({
currency: "AUD" // set the currency to pounds sterling
});
simpleCart({
cartColumns: [
{ attr: "name" , label: "Name" } ,
{ attr: "size", label: "Size"},
{ attr: "price" , label: "Price", view: 'currency' } ,
{ view: "decrement" , label: false , text: "-" } ,
{ attr: "quantity" , label: "Qty" } ,
{ view: "increment" , label: false , text: "+" } ,
{ attr: "total" , label: "SubTotal", view: 'currency' } ,
{ view: "remove" , text: "Remove" , label: false }
]
});
simpleCart({
checkout: {
type: "SendForm",
url: "umbraco/surface/cart/cart"
}
});
</script>
我的 MVC 控制器:
// POST: cart
[HttpPost]
public ActionResult cart(string contents)
{
var test = JsonConvert.DeserializeObject(contents);
return null;
}
有人知道如何解决这个问题,让它真正读入控制器吗?我尝试使用与购物车相同的数据制作模型,但仍然为空。
【问题讨论】:
-
你有什么错误吗..你能在控制器中调试吗.....
-
没有错误,对象作为 null 传入,如上所述。没有错误,正常进入控制器。
-
使用 Html.BeginForm 参考:stackoverflow.com/questions/8356506/…
-
据我所知,这不是 simplecart 的工作方式。
标签: c# asp.net-mvc simplecart