JQuery function – Run it automatically once a day instead of a on click action

I am new to JavaScript and JQuery.

We have a WordPress theme serving as an online directory. This theme uses a JSON file to display our listings on our map. For each of our modifications on a listings we must click on a button named “JSON Generator” to update the data of the map. The problem is that we are currently adding / modifying a lot of content on our map so it requires a lot of manual regenerations.

Screenshot of the button and his html declaration

Is there a way to replace the ON CLICK launch of the JavaScript function regenerating the JSON by an automatic launch every 24 hours for example?

Here is the start of my actual .js file :

;( function( $ ){



// Json Generator

var directoryManagerAdmin = function () {

    this.param = lava_dir_admin_param;

    this.init();

}



directoryManagerAdmin.prototype.constructor = directoryManagerAdmin;

directoryManagerAdmin.prototype.init = function() {

    var self = this;

    $( document )

        .on( 'click', '.lava-data-refresh-trigger', this.onGenerator() )

        .on( 'click', '.fileupload', this.image_upload() )

        .on( 'click', '.fileuploadcancel', this.image_remove() )



    $('button[data-listing-type-generator]').each(function(){

        var listingType = $(this).data('listing-type-generator') || false;

        var Instance = self.onGenerator(listingType);

        $(this).on('click', Instance);

    });

    self.bindJsonEditor();

}

directoryManagerAdmin.prototype.onGenerator = function(type) { THEN YOU HAVE THE VERY LONG FUNCTION....

I think that I have to replace the launcher : .on( 'click', '.lava-data-refresh-trigger', this.onGenerator() ) by an automatic launcher every 24 hours or so.

I found out how to get the current date : var date = new Date().toLocaleDateString();, I also know that I may have to use the setInterval action but I don’t know how to use it 🙁

Thanks by advance if you have any clue to help me !