5

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

1 Answer 1

8

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.

1
  • 1
    Yes. Here is WordPress Heartbeat API which allows to send any additional data to the server. I thought to write a detailed response but it seems you already solve your issue :) Commented Aug 24, 2016 at 16:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.