I am trying to toggle between 2 images based on a condition. I am thinking to change the src of img tag.
I am able to change the src but on the webpage the image is not getting updated.
can someone point out where or what should be used or updated.
Here is my JS code ->
success: function(data){
if(data.status == 200){
if(data.message == "Liked"){
document.getElementById("like_image_state_change").src="{% static 'FrontEnd1/Static_Images/CovrPage_Like_R.png' %}";
}
else if(data.message == 'Like Removed'){
document.getElementById("like_image_state_change").src="{% static 'FrontEnd1/Static_Images/CovrPage_Like_W.png' %}";
console.log(document.getElementById("like_image_state_change"));
}
}
else{
console.log('wrong');
}
}
});
Here when I console the document.getElementById in 'like Removed' I could see the updated src for the Image but the Image is still the same on the webpage.
PS -> The backend I am using is DJango. (if it matters)