JSFiddle - React, Tailwind, and code Playground
HTML
<div id="output">
f
</div>
<button class="foo">
Click me
</button>
<button class="not-foo">
Other ajax
</button>
JavaScript
$(function() {
$(document).ajaxStop(function() {
if(foo_flag) {
foo_flag = false;
alert('done');
location.reload(true);
}
});
var foo_flag = false;
$('.not-foo').click(function() {
$.ajax({
method: 'post',
data: {
html: 'wololo'
},
url: '/echo/html/',
success: function(result) {
$("#output").append(result);
}
});
});
$('.foo').click(function() {
foo_flag = true;
for(i = 0; i < 16; i++) {
$.ajax({
method: 'post',
data: {
html: 'bar',
},
url: '/echo/html/',
success: function(result) {
$("#output").append(result);
}
});
}
});
});