$(document).ready(function () { check_status(); setInterval(() => check_status(), 25000); function check_status() { $.each($('.server_status'), function(e) { var message = { url: $(this).data('url'), } $.ajax({ type:'POST', url: '/server_status', processData: false, // tell jQuery not to process the data contentType: false, // tell jQuery not to set contentType data: JSON.stringify(message), success: (data) => { $(this).html(data['status']+' '+data['ssl_status']); $(this).css( "color", data['status_color'] ); }, error:function (jqXHR, exception) { } }); }) } });