How can I dynamically add an IFRAME using JavaScript to content that is refreshed via AJAX? Consider the following example:
$('#bar').delegate('.scroll-content-item span a', 'click', function() {
var object_id = $(this).parent().attr("class");
$.ajax({
type: "POST",
url: "/myfunction.php",
data: "action=object_id=" + object_id,
dataType: "json",
success: function(data){
$('.info').html(data['html']);
}
});
return false;
});
I attempted to insert this code upon successful completion of the AJAX call:
document.write('<IFRAME vspace=0 height=71 style="padding:10px" marginHeight=5 src="" frameBorder=0 width=54 name="pliggit" scrolling=no><script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script><script type="text/javascript">stLight.options({publisher:"b24b6378-26a9-435c-ac5f-8aee4f59529c"});</script></IFRAME>');
However, I encountered an error stating Unterminated string literal
.