function update_element(url, element_id, error_message, max_errors=6, on_finish=null) {
    checkBox = document.getElementById("pauseUpdates")
    if (checkBox == null || typeof checkBox  === "undefined" || checkBox.checked == false) {
        $.get(url + window.location.search, function(data){
            $("#" + element_id).html(data);
            errors_count = 0;
        }).fail(function() {
            if (errors_count === undefined) {
                var errors_count = 100;
            } else {
                errors_count++;
            };
            if (errors_count >= max_errors) {
                $("#" + element_id).html(error_message);
                var highestIntervalId = setInterval(";");
                for (var i = 0 ; i < highestIntervalId ; i++) {
                    clearInterval(i); 
                };
                if (on_finish !== null) {
                    //console.log('Finished by calling: ' + on_finish);
                    on_finish();
                };
            };
        });
    };
};
