JavaScript的\ jQuery的:
javascript\jQuery:
var items = new Array();
var obj { Begin: "444", End: "end" };
items.push(obj);
items.push(obj);
var request = {
DateStart: $("#DateStart").val(),
mass: items
};
$.post("/Home/Index", request, null,
"json");
C#的mvc指数控制器
C# Mvc Index Controller
public class MyClass
{
public string Begin;
public string End;
}
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Index(
string DateStart,
MyClass []mass)
{
System.Diagnostics.Debug.WriteLine(mass[0].Begin);
}
如何执行此code?谢谢。
how to execute this code? thanks.
U可以不通过质量:项目
,并期望它能够自动序列化为一个JSON数组,你要么需要迭代和构建JSON(坏的计划),或使用 JSON库(好的计划)
U can't pass mass: items
and expect it to be serialized as a JSON array automatically, you will need to either iterate and construct the JSON (bad plan) or use a JSON library(good plan)
上一篇:Rails的3 AJAX请求的真实性令牌忽略令牌、真实性、Rails、AJAX
下一篇:如何与QUOT;流" JSON从服务器到客户端使用的JavaScript客户端、服务器、QUOT、JSON