I am using jQuery append()
function to to add tag and tag after ajax response, but when it appends image tag is starts displaying images. Instead of that, it should display message you received an image.
Here is what I am doing
$.ajax({
type: "GET",
url: `/get_unread_count/${conversation.id}`,
success: function (data) {
var unread_count = data.unread_count;
if(unread_count > 0){
var count_html = ` <div class="kt-widget__action">
<span class="kt-widget__date"></span>
<span class="kt-badge kt-badge--success kt-font-bold mr-2">${unread_count}</span>
</div>`;
}else{
var count_html = '';
}
$('.kt-widget__items').append(`
<div class="kt-widget__item" id="${conversation.messageable_type}" onclick="message(${conversation.conversation_id},${conversation.messageable_id},this,'${name}',${id});appendRealTimeMessage(${conversation.conversation_id});">
<span class="kt-media kt-media--circle">
<img src="/business_logo/${logo}" alt="image">
</span>
<div class="kt-widget__info">
<span class="kt-widget__desc ">
${conversation.conversation.last_message.body ?? ''}
</span>
</div>${count_html}
</div>`);
conversation.conversation.last_message.body
is having message body which could have img tag
What I want is if there is an image tag it should display message you received an image .
How is that possible?
question from:
https://stackoverflow.com/questions/65644414/how-avoid-image-tag-while-appending-tags 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…