Ajax load

This example shows how to call Redactor for loaded content with Ajax request.

    Demo

    Code

    <!-- button -->
    <button onclick="load();">Click</button>
    
    <!-- box -->
    <div id="redactor-box"></div>
    
    <!-- load -->
    <script>
    function load()
    {
        var request = new XMLHttpRequest();
        request.open('GET', 'redactor.html', true);
        request.onload = function()
        {
            if (request.status >= 200 && request.status < 400)
            {
                var box = document.getElementById('redactor-box');
                box.innerHTML = request.responseText;
    
                // call
                $R('#content', { focus: true });
            }
    
        };
        request.send();
    }
    </script>
    
    <!-- redactor.html -->
    <textarea id="content">...</textarea>
    <!-- / redactor.html -->