JSFiddle - React, Tailwind, and code Playground

HTML

<input type="button" id="saveBtn" value="save"/>

JavaScript

var stuff = {}

  $(function() {
    stuff = new Test(1, 'testName')
  });

function Test(id, name)
{
  this.id = id,
  this.name = name
  
  this.save();
}

Test.prototype.save = function(){
  var _self = this;
  
  $('#saveBtn').on('click', function() {
    $.post("/echo/json/", _self)
      .done(function(){
         alert('success');
       });
  })
}  

Test.prototype.validate = function(){
  var _self = this;
}