JSFiddle - React, Tailwind, and code Playground

by WILLIAM CORREA

HTML

<button id="btn_copy">
My Button
</button>

<button id="btn_ajax">
Ajax Me
</button>

JavaScript

const App = {
	prettyThing: function (what) {
    what = typeof what === 'string' ? what : 'Click thing';
    alert(what);
	},
  ajax: function () {
    $.ajax({
      type: 'GET',
      url: '/echo/json',
      dataType: 'json',
      success (data) {
        App.prettyThing('Success!');
      },
      error (err) {
        App.prettyThing('Whoops!');
      }
    });
  },
  register: function (scope) {
  	scope.App = this;
  	$('#btn_copy').click(App.prettyThing);
		$('#btn_ajax').click(App.ajax);
  }
};

App.register(window);

window.setTimeout(() => {
	App.prettyThing('A setTimeout thing');
}, 2000);