且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

异步功能中可观察的设定值

更新时间: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);
        }
    });
}