JSFiddle - React, Tailwind, and code Playground
HTML
<a href="#" onclick="return runAjax();"> Set myProfile 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: "http://tiffintom.com/api/private/request/data",
type: "POST",
dataType: "json",
data: {
"RESTAURANT":{"APIKEY":"DoPUQBErcpKPtRmbjpcFvbb8YCMeBjr4w6OcyjtA"},
"REQUESTPARAM":[
{
"MODULE":"putitem",
"METHOD":"myProfile",
"PARAMS":{
"CUSTOMERID": 530,
"STREET": "zmcbxnzxn mcbn",
"POSTCODE": "WS1 4BA",
"COUNTRY": "United Kingdom",
"MOBILE": "0987456123",
"TOWN" : "abc" //optional
}
},
],
},
success:function(data) {
console.log(data);
$("#responseData").html(JSON.stringify(data));
},
error: function () {
$('#responseData').html('There was an error!');
}
});
return false;
}