-1
I need to insert the HTML that refers to an image with hyperlink received through an ajax function on the page, but for security reasons I can’t just insert directly, so I’m passing this HTML code through the . text() to a created div, and only after I assign this variable to . html(), but what is happening is that only the created div is recognized as HTML, the rest is displayed in plain text. How do I get everything recognized as HTML when inserting into my page, while maintaining insert security?
function start(){
timer = setInterval( function(){
var banner = $('<div>').text(banner()); // <a href="http://exemple.com/"><img src="imagem.jpg"/></a>
$('#parceiros').html(banner);
}, 3000);
}
var banner = $('<div>').text(banner());
?? you are defining the variablebanner
and calling as a functionbanner()
within the.text()
? Can you explain it better?– Sergio
@Sergio is right, this line should generate an error. You checked the browser console?
– bfavaretto
I believe it was only one case in which the deletion of code and reuse of nomenclatures ended up generating this small confusion. The variable banner receives the return value of a function banner() and places it inside a DIV which is later added to the ID element partners.
– Bruno Augusto