<script type="text/javascript">
$(function () {
var obj = { name: "军需品", myclass: [{
one: 1,
two: 2,
three: 3
}, {
one: 11,
two: 22,
three: 33
}, {
one: 111,
two: 222,
three: 333
}]
}; $.ajax({
url: '<%=Url.Content("~/Home/GetList") %>',
type: 'POST',
dataType: 'json',
data: JSON.stringify(obj),
contentType: 'application/json; charset=utf-8',
success: function (data, state) {
alert(JSON.stringify(data));
alert(state);
}
});
});
</script>
前端Jquery Ajax请求
public class HomeController : Controller
{
//
// GET: /Home/ public ActionResult Index()
{
return View();
} public ActionResult GetList(Myobj a)
{
return Json(a);
}
} public class Myobj
{
public string name { get; set; }
public List<MyClass> myclass { get; set; }
} public class MyClass
{
public int one { get; set; }
public int two { get; set; }
public int three { get; set; }
}
asp.net mvc后端接收
注意:集合的名称必须相同