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();
}
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.