Submit editor content via JavaScript fetch() instead of a traditional form post. The response is displayed without a page reload.
<richtextbox id="ajaxEditor" name="ajaxEditor"
toolbar="default" height="300px" />
<button onclick="submitAjax()">Ajax Submit</button>
<script>
function submitAjax() {
var editor = document.getElementById('ajaxEditor');
var html = editor.value;
fetch('/api/save', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ html: html })
})
.then(response => response.json())
.then(data => console.log('Saved:', data));
}
</script>