This question already has answers here:
</div>
</div>
<div class="grid--cell mb0 mt8">Closed <span title="2012-10-12 08:08:17Z" class="relativetime">7 years ago</span>.</div>
</div>
</aside>
Possible Duplicate:
jquery .text doesn’t render HTML elements into the DOM
I have an AJAX function pulling an <img>
tag from the server. My problem is, when I set the .text()
property of a span
on the page to that <img>
tag, the HTML is not rendered. Rather, it just displays the tag as text.
Here is my code:
// jQuery
$.ajax({
url: 'forms/scripts/getStatus.php',
dataType: 'json',
type: 'POST',
data: {
subfolderID:rowID
},
async: false,
success: function(data){
if(data.errorsExist == "Y"){
alert(data.appError);
}
else{
$("#trackStatus").text(data.status);
}
},
error: function(){
alert("Error! Could not retrieve tracking status");
}
});
My HTML:
<td><span id="trackStatus"></span></td>
How can I get the img
tag to render as HTML? Maybe I shouldn't be using a span
with the .text()
method...?
</div>