Request.HTML
Sends HTML code to backend updates target div and executes <script>
HTML
<div id='target_div'>Target</div>
JavaScript
var r = new Request.HTML({
url: '/ajax_html_echo/',
data: {'html': "hello"},
method: 'post',
update: 'target_div',
onSuccess: function(response) {
(function() {
go();
}).delay(1000);
}
});
var counter = 0;
var go = function() {
counter++;
r.cancel().setOptions({
data: {html: "attempt " + counter}
}).send();
};
go();