JSFiddle - React, Tailwind, and code Playground
HTML
<div class="example">
<a href="javascript:void(0);" class="button">Click here</a>
</div>
JavaScript
$('.button').on('click', function()
{
// change button text
$(this).html('Loading..').delay(10);
// do async call
$.ajax({
url: 'http://echo.jsontest.com/insert-key-here/insert-value-here/key/value',
async: false,
dataType: "json",
success: function(poResponse){
console.log(poResponse);
}
});
// change button text
$('.button').html('Done');
// put Click here back after a second, for repeation of the test
setTimeout(function() { $('.button').html('Click here'); }, 1000);
});