How to update post with Ajax (no plugin)

This question is old, but for future reference, check out the answer I gave on the original question here. The gist is:

Confirmation Dialog

The alert is generated in wp-admin/js/post.js and wp-includes/js/autosave.js. Theoretically, you should be able to use the following line of code in your $.post success function:

wp.autosave.initialCompareString = wp.autosave.getCompareString();

But that doesn’t seem to work. Instead, you can supercede the beforeunload function as so:

// Replaces wp.autosave.initialCompareString
var ajax_updated = false;

// Supercede the WP beforeunload function                  
$(window).unbind('beforeunload.edit-post');
$(window).on( 'beforeunload.edit-post', function() {
        var editor = typeof tinymce !== 'undefined' && tinymce.get('content');

        // Use our "ajax_updated" var instead of wp.autosave.initialCompareString
        if ( ( editor && !editor.isHidden() && editor.isDirty() ) ||
                ( wp.autosave && wp.autosave.getCompareString() != ajax_updated) ) {
                return postL10n.saveAlert; 
        }
});    

And then change ajax_updated to the right content in your $.post success function, as so:

// Mark TinyMCE as saved
if (typeof tinyMCE !== 'undefined') {
        for (id in tinyMCE.editors) {
                var editor = tinyMCE.get(id);
                editor.isNotDirty = true;
        }
}   
// Update the saved content for the beforeunload check
ajax_updated = wp.autosave.getCompareString();

Adding an alert message

You also asked about adding an alert message. You could do that a lot of different ways. The simplest and ugliest would be to use the javascript alert() function, like this:

alert("Post saved");

Personally, I prefer the jquery notify library. After including the library, you would place this in your success and failure functions, respectively:

$.notify('Post saved','success');
$.notify('Something went wrong','error');