Serialize and Ajax

This example shows how to send the serialized Redactor content with jQuery Ajax function.

Code

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

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

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

</form>

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

<!-- send function with jQuery -->
<script>
function sendForm()
{
    $.ajax({
        url: '/savedata-server-script/',
        type: 'post',
        data: $('#my-form').serialize()
    });
}
</script>