我試圖用淘汰賽映射插件,但它不是將數據綁定到我的UI。以下是我的代碼:問題與淘汰賽映射插件
var model;
$(document).ready(function() {
$.ajax({
type: "POST",
url: SERVER_PATH + '/jqueryservice/DataAccessService.asmx/GetData',
async: false,
data: "{ }",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (result, status) {
model = ko.mapping.fromJS(result.d);
},
error: GetDataError
});
});
function GetDataError() {
alert("System is not responding at the moment. Please try again.");
}
任何人都可以請讓我知道我在做什麼錯在這裏?以下是這是一個從服務器返回的數據:
{"ID":903,"Name":"Camela Holding","Email":"[email protected]",
"Vehicles":[{"ID":1,"Name":"Van"},
{"ID":2,"Name":"Car"},
{"ID":4,"Name":"Cadillac"},
{"ID":5,"Name":"Train"}, {"ID":3,"Name":"Jeep"}],
"OwnerVehicle":0,"WeeklyData":null,"Week1":null}
try model = ko.mapping.fromJS(result); – 2013-03-17 06:39:01
你在哪裏調用'ko.applyBindings(model);'? – nemesv 2013-03-17 06:39:40
你有什麼行爲?錯誤警報或不正確的輸出?你的結果沒有'd'。爲什麼KO模型綁定到'result.d'? – 2013-03-17 06:45:16