Request.HTML

Sends HTML code to backend updates target div and executes <script>

by Dimitar Christoff

HTML

<div id='target_div'>Target</div>

JavaScript

var counter = 0;
(function go() {
    counter++;
    new Request.HTML({
        url: '/ajax_html_echo/',
        data: {'html': "hello " + counter},
        method: 'post',
        update: 'target_div',
        onSuccess: function(response) {
            go();
        }
    }).send();
})();