JSFiddle - React, Tailwind, and code Playground

by rippo

HTML

<script src="https://github.com/downloads/SteveSanderson/knockout/knockout-2.1.0.js"></script>
<div data-bind="text: description"></div>

JavaScript

var viewModel = function() {

    var self = this;
    self.description = ko.observable();

    self.get = function(words) {
        return $.ajax({
            url: "/echo/json",
            dataType: "json",
            type: "POST",
            data: {
                "text": words
            },
            success: function(data) {
                self.description(words);
            },
            error: function(data) {

            }

        });
    };

};

$(function() {

    var instance = new viewModel();
    ko.applyBindings(instance);

    $.when(instance.get('something')).then(function() {
        instance.description('post promise');
    });

});