I have data like:
<p>50 Roses in a Heart Shape<span style="font-family: Arial, Helvetica, sans-serif; line-height: 15px;">; Make your recipient the princess of the day with this lovely and luxurious bouquet.<\/span><\/p>\u000d\u000a
which i want to append to my div dynamically from jquery. How do I do that?
Here is what I am doing:
var param = '{"CategoryId":72}';
$.ajax({
type:'POST',
url : serviceUrl,
dataType:"json",
data:param,
contentType: "application/json; charset=utf-8",
dataType: "json",
async: true,
cache: false,
success : function (msg) {
$.each(msg, function(index, table) {
var data=' <div class="ui-block-c">';
data+=' <div class="ui-body ui-body-d">';
data+=' <h4>'+table.Name+'</h4>';
data+=' <p>';
data+= table.Description;
data+='</p>';
data+=' <img src="img/pink coral roses.jpg" alt="" style="width:100%;">';
data+=' <p>'+table.Price+'</p>';
data+=' <button class="ui-btn ui-btn-inline">Add To Cart</button>';
data+=' </div>';
data+=' </div>';
alert(data);
$('.mainGrid').append(data);
});
},
error : function (XMLHttpRequest, textStatus, errorThrown) {
alert('Error in LoadLayout');
}
});
Here table.Description
returns the string I mention on top and .mainGrid
is the class of the div I want to append data to. My above code does not render the string as Html. How do I do that?