JSFiddle - React, Tailwind, and code Playground

by mlsteeves

HTML

<html>
<body>
    <div id="Error">CLICK HERE - Error</div>
    <div id="Works">CLICK HERE - works</div>
</body>
</html>

JavaScript

/*
    Test ??? through ajax with jquery.
*/

$('#Error').click( function(){    
    var jsonCausesError = '{"comment":"???"}';
    sendAjax(jsonCausesError );
});

$('#Works').click(function(){
    var jsonWorks = '{"comment":"works"}';
    sendAjax(jsonWorks);
});

function sendAjax(jsonString){
    $.ajax({
        type: "POST",
        url: '/echo/json/',
        data: jsonString,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        processData: false,
        success: function(retVal, textStatus, jqXHR){
            alert('success');
        },
        error: function(jqXHR, textStatus, errorThrown){
            alert('errorThrown: ' + errorThrown);
        },
    });
}