JSFiddle - React, Tailwind, and code Playground
by Tariqul Islam
HTML
<a href="#" onclick="return runAjax();"> Reservation State Check </a>
<div id="responseData">
Waiting for Action...
</div>
CSS
#responseData {
margin-top: 15px;
font-family: "Arial"
}
JavaScript
// handles the click event, sends the query
function runAjax() {
$("#responseData").html("Collecting your Data...");
$.ajax({
url: "https://tiffintom.com/api/private/request/data",
type: "POST",
dataType: "json",
data: {
"RESTAURANT":{"APIKEY":"jurd3WvjnweVASwx6oU5kwuA1mBAo9vwtMAnyUvL"},
"REQUESTPARAM":[
{
"MODULE":"getitem",
"METHOD":"reservationState"
}
]
},
success:function(data) {
console.log(data);
$("#responseData").html(JSON.stringify(data));
},
error: function () {
$('#responseData').html('There was an error!');
}
});
return false;
}