我通过AJAX从数据库获取HTML,但当我将该HTML输出到div中时,它只显示实际的HTML文本,而不是像浏览器一样显示图片等内容。有谁知道如何做到这一点吗? 我正在将HTML输出到textarea #html中,并希望在div #preview中看到它呈现出来。以下是代码:
$(document).ready(function(){
$('#creative').change(function() {
$.ajax({
url: '/app/components/MailingsReport.cfc',
//POST method is used
type: "POST",
//pass the data
data: {
method: "getCreativeHTML",
creativeID: $('#creative').val(),
datasource: "shopping_cart"
},
dataType: "html",
//contentType: "application/text; charset=utf-8",
success: function(response){
var obj = $.trim(response);
//alert("response");
if (obj == '"0 records"') {
$('#preview').html("No creative found.");
}
else {
$('#html').val( obj );
$('#preview').html( obj );
}
}
})
});
});
#preview
中? - Robert Niestroj