JSFiddle - React, Tailwind, and code Playground
HTML
<div class="document">
<a class="ajax" href="#">Fire an AJAX request</a>
</div>
JavaScript
$(function() {
$(".ajax").ajaxStart(function() {
$(".document").append("<br>ajax begun");
});
$('.document').on('click', '.ajax', function(e) {
e.preventDefault();
// ajax request
$.ajax({
async: true,
cache: false,
type: 'post',
url: '/echo/html/',
data: {
html: '<p>This is echoed the response in HTML format</p>',
delay: 1
},
dataType: 'html'
}).done(function(data){
$(".document").append("<br>" + data);
});;
});
});