JSFiddle - React, Tailwind, and code Playground

by Tony Huy

HTML

<button id="get_data_ajax">Get Data using $.ajax</button>
<div id="result"></div>

JavaScript

$('#get_data_ajax').click(function(){
    $.ajax({
        dataType: "json",
        url: "http://portal.parksensei.com/api/v1/configuration?username=&password=",
        data: {
            // this is just how to get /echo/json to return the json, your post data shouldn't need to be JSON.stringified
            json: JSON.stringify({
                text: 'some text',
                array: [1, 2, 'three'],
                object: {
                    par1: 'another text',
                    par2: [3, 2, 'one'],
                    par3: {}
                }
            })
        },
        success: function(data) {
            console.log(data);
            $('#result').html(JSON.stringify(data));
        }
        
        error: function(){
            console.log('error');
        }
    });
});