JSFiddle - React, Tailwind, and code Playground

by Christopher McCulloh

HTML

<!--div id="log">JSON POST</div-->
<div id="log2">JSONP GET</div>

JavaScript

function updateMap(){
    var getRequest = $.ajax({
        url: "http://23.21.120.66/events/",
        type: "GET",
        data: {
            "type": "purchase"
        },
        crossDomain: true,
        dataType: "jsonp"
    });
    
    getRequest.done(function(msg) {
        console.log('success');
        console.log(msg);
        $("#log2").prepend('<h1>'+msg[0].type + "@" + +msg[0].location+'</h1>');
    
    });
    
    getRequest.fail(function(jqXHR, textStatus) {
        console.log("error");
        console.log(jqXHR);
        $("#log2").html("JSONP GET Request failed: " + textStatus);
    });
}

var intervalID = window.setInterval(updateMap, 3000);
$("#log2").html('');
updateMap();