0
我試圖通過淘汰賽如下對象,
當我通過使用// ko.utils.postJson數據不作任何Ajax的數據傳遞給我的控制器的「任務」,但是當我嘗試阿賈克斯後,我得到了任務淘汰賽對象
function TaskListViewModel() {
var self = this;
self.availableMeals = [
{ UserName: "Standard", UserId: 0 },
{ UserName: "Premium", UserId: 34 },
{ UserName: "Ultimate", UserId: 290 }
];
self.save = function() {
// ko.utils.postJson(location.href, { task: this.availableMeals });
$.ajax(location.href,{
data: ko.toJSON({ task: this.availableMeals });,
type: 'POST',
dataType:'json',
contentType: 'application/json',
success: function (result) { alert(result) }
});
};
}
ko.applyBindings(new TaskListViewModel());
到控制器下面一個空值,
[HttpPost]
public ActionResult About([FromJson] IEnumerable<UserProfile> task)
{
return RedirectToAction("Login","Account");
}
什麼是...任務的價值:this.availableMeals何時發佈。它是有效的JSON。 – Kieran