Callback for wp.autosave.server.triggerSave();

I'm using following code to force WordPress page to save post as draft, is there any callback function for it, I want to alert a text after it complete saving post as draft.

if ( wp.autosave.server ) {
wp.autosave.server.triggerSave();
}

Topic autosave callbacks pages posts Wordpress

Category Web


So I found the solution, callback function for when post or page is:

jQuery(document).on('heartbeat-tick.autosave', function( event, data ) {
    // your code here
});

This uses the Wordpress Heartbeat API.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.