zoukankan      html  css  js  c++  java
  • Knockout

    <button id="load">Load</button>
    <ul data-bind="template: { foreach: vendors }">
    <li><span data-bind="text: Id"></span></li>
    </ul>

    var data = [];
    var viewModel = {
    vendors: ko.observableArray(data)
    };
    ko.applyBindings(viewModel);

    $(function () {
    // on this click event, we popular the observable array
    $('#load').click(function () {
    // WORKS. Html is updated appropriately.
    viewModel.vendors([{ "Id": "01" },{ "Id": "02" },{ "Id": "03" }]);

    $.ajax({
    url: '/echo/json/',
    type: "POST",
    /*contentType: "application/json; charset=utf-8",*/
    data:{
    json: JSON.stringify( {
    result:[{ "Id": "02" },{ "Id": "03" },{ "Id": "04" }]
    }),
    delay: 3
    },
    dataType: 'json',
    success: function (data) {
    console.log(data);
    viewModel.vendors(data.result);
    }
    });
    });
    });

  • 相关阅读:
    zbb20180930 Postman 使用方法详解
    Cookie、Session、jsp、EL、JSTL
    Http协议、Tomcat、servlet
    xml、网络编程、 反射
    JDBC、DBUtils
    Java IO流对象、多线程
    mySql
    Java基础
    VueJs
    GIT
  • 原文地址:https://www.cnblogs.com/zwei1121/p/3709392.html
Copyright © 2011-2022 走看看