更新时间:2022-03-29 09:35:35
How I do it is by using the Knockout Mapping Plugin and the fromJSON
command (you might need to use fromJS
depending on your data format) this maps the data as it comes from the source.
function getDataFromJson() {
$.ajax({
url: 'http://localhost:56253/test/3?format=json',
dataType: 'json',
success: function (data) {
ko.mapping.fromJSON(data, {}, self.dataArray);
}
});
}