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…?
use
.html()instead of.text()