Get content with API

This example shows how to get the content of Redactor with API and send to the server with jQuery Ajax.

Code

<!--form -->
<form action="/server-script/" method="post">

    <!-- element -->
    <textarea id="content" name="content"></textarea>

    <!-- submit button -->
    <button onclick="sendForm();">Send</button>

</form>

<!-- call -->
<script>
$R('#content');
</script>

<!-- get and send content with API -->
<script>
function sendForm()
{
    var content = $R('#content', 'source.getCode');

    $.ajax({
        url: '/savedata-server-script/',
        type: 'post',
        data: 'content=' + content
    });
}
</script>