2012-10-11 51 views

回答

4

你可以把它作爲一個AJAX請求:

var model = [{"Title":"test","Description":"tset","Price":"500.00","Status":"Reserved"}, {"Title":"s","Description":"d","Price":"400","Status":"Reserved"}]; 
$.ajax({ 
    url: '/somecontroller/someaction', 
    type: 'POST', 
    contentType: 'application/json; charset=utf-8', 
    data: JSON.stringify(model), 
    success: function(result) { 

    } 
}); 

,然後你將有一個控制器動作,將接收到這個請求:

[HttpPost] 
public ActionResult SomeAction(IEnumerable<MyViewModel> model) 
{ 
    ... 
} 

其中MyViewModel會的當然體現JSON結構:

public class MyViewModel 
{ 
    public string Title { get; set; } 
    public string Price { get; set; } 
    public string Status { get; set; } 
} 
相關問題