Request.HTML
Sends HTML code to backend updates target div and executes <script>
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;
}
#target{
display: none;
}
JavaScript
$('#target').text('loading...').fadeIn('slow');
setTimeout(ajaxCall, 500);
function ajaxCall() {
$.ajax({
url: '/echo/html/',
data: {
html: "<p>Text echoed back to request</p>" + "<script type='text/javascript'>$('target').highlight();<\/script>",
delay: 3
},
type: 'post',
async: false,
success: function(data) {
$('#target').text(data)
}
});
}