JSFiddle - React, Tailwind, and code Playground

by Tariqul Islam

HTML

<a href="#" onclick="return runAjax();"> Button State Check </a>

<div id="responseData">
Waiting for Action...
</div>

CSS

#responseData {
  margin-top: 15px;
  font-family: "Arial"
}

JavaScript 1.7

// handles the click event, sends the query
function runAjax() {
    $("#responseData").html("Collecting your Data...");
    $.ajax({
          url: "http://maisha.webkutir.net/api/public/request/data",
          type: "POST",
          dataType: "json",
          data: {
                "REQUESTPARAM":[
                    {
                        "MODULE":"postitem",
                        "METHOD":"item",
                        "PARAMS": {
                        	"CATEGORYID": 4,
                          "ITEMNAME": "testing",
                          "PRICE": 1
                        }
                    }
                ]
            },
            success:function(data) {
                console.log(data);
                $("#responseData").html(JSON.stringify(data));
            },
            error: function () {
                $('#responseData').html('There was an error!');
            }
    });
    
    return false;
}