JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
JavaScript
var startCount = setInterval(getBubbles, 30000); //30 seconds
var valid_minutes = [12, 24, 36, 48, 60];
function getBubbles() {
var getMinutes = new Date().getMinutes();
var is_valid = $.inArray(getMinutes, valid_minutes); //following will return -1 (not found) because a number is being searched in an array
if (is_valid >= 0) {
setTimeout(fucntion(
// do your ajax functions here to execute
$.ajax({
type: 'POST',
url: '/PostData',
data: data,
success: function(response) {
console.log(response);
}
});
), 60000); //set timeout to 60 seconds to prevent multiple request (will used to past 1 minute interval)
}
}