Finally found the problem. The action: save_post
was missing from data in ajax call. This code works:
<script>
jQuery( document ).ready(function() {
jQuery('input[type=button]').on('click', function() {
var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>";
jQuery.ajax({
type: "POST",
data: {
data:jQuery('.event-form').serialize(),
action: 'save_post'
},
url: ajaxurl,
success: function(result) {
console.log('data sent!');
console.log('sent to: ' + templateDir + loadUrl );
},
error: function(jqXHR, textStatus, errorThrown) {
console.log(jqXHR + " :: " + textStatus + " :: " + errorThrown);
}
});
});
});
</script>