jQuery post array - ASP.Net MVC 4

 list = new Array();
 list.push({ "step": 1, "position": 1 });
 list.push({ "step": 2, "position": 2 });
 list.push({ "step": 3, "position": 3 });

$.ajax({
        type: 'Post',
        cache: false,
        url: '/Workflow/Home/UpdateStepPositions',
        data: JSON.stringify({ 'steps': list }),
        contentType: 'application/json; charset=utf-8',
        async: false,
        success: function (data) {
            console.debug(data);
        },
        error: function (data) {
            console.debug(data);
        }
    });

 Controller
   [HttpPost]
    public ActionResult UpdateStepPositions(List<UpdatedSteps> steps){
        var bresults = new {
            Success = false,
            Message = "Unable to update step positions."
        };

        return Json(bresults);
    }

   Class
   public class UpdatedSteps {
    public string Step { get; set; }
    public string Position { get; set; }
}

 

おすすめ

転載: blog.csdn.net/wangyue4/article/details/121265956