码迷,mamicode.com
首页 > Web开发 > 详细

.net mvc ajax list post

时间:2015-05-14 15:51:24      阅读:108      评论:0      收藏:0      [点我收藏+]

标签:

http://stackoverflow.com/questions/13242414/passing-a-list-of-objects-into-an-mvc-controller-method-using-jquery-ajax

ajax 传递集合 给 mvc 的Action

$(document).ready(function () {
    var things = [
        { id: 1, color: yellow },
        { id: 2, color: blue },
        { id: 3, color: red }
    ];      

    things = JSON.stringify({ things: things });

    $.ajax({
        contentType: application/json; charset=utf-8,
        dataType: json,
        type: POST,
        url: /Home/PassThings,
        data: things,
        success: function () {          
            $(#result).html("PassThings()" successfully called.);
        },
        failure: function (response) {          
            $(#result).html(response);
        }
    }); 
});


public void PassThings(List<Thing> things)
{
    var t = things;
}

public class Thing
{
    public int Id { get; set; }
    public string Color { get; set; }
}

 

.net mvc ajax list post

标签:

原文地址:http://www.cnblogs.com/bingguang/p/4503135.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!