JSFiddle - React, Tailwind, and code Playground

by mattbaker

HTML

<div id="status"></div>
<div id="ajax"></div>

JavaScript

$.post("/echo/json/", {json:{error:true}})
    .done(function (response) {
        if (response.error) {
            $("#status").html("an error occurred");
        } else {
            $("#status").html("Success!");
        }
    })
    .fail(function (response) {
        $("#status").html("A server error occured (failing http status code)");
});
$.ajax({
  type: 'POST',
  url: '/echo/html/',
  data: {
    'html': 'Echo!'
  },
  success: function(data) {
    $('#ajax').html(data);
  },
  dataType: 'text/html'
});