Request.HTML
Sends HTML code to backend updates target div and executes <script>
by Dimitar Christoff
HTML
<div id='target'><p>This text will be replaced in 3 seconds</p></div>
CSS
body {
font-family: Helvetica, Sans, Arial;
}
p {
padding: 10px;
}
JavaScript
new Request({
url: '/secho/html/',
data: {
html: "<p>Text echoed back to request</p>" + "<script type='text/javascript'>$('target').highlight();<\/script>",
delay: 3
},
method: 'post',
onFailure: function() {
var error = "Error " + this.status;
switch (this.status) {
case 404:
error = "Document not found (404)";
break;
case 301:
error = "Object moved permanently (301 redirect)";
break;
case 302:
error = "Object moved temporarliy (302 redirect)";
break;
}
alert(error);
}
}).send();