How can I replace HTML code with the 'for from django' function using a jQuery AJAX call?
$.ajax({
url: url,
data: $('#FormSite').serialize(),
type: "POST",
async:false,
success: function(response) {
$($("#Pic").first()).replaceWith($(response['Pic']));
$("#HeaderWpis").text(response['h1']);
$("#WpisChild").html("<div id='WpisChild'> {% for News in Messags %} <p>{{ News.title }}</p> </div>");
},
error: function(data)
{
alert('Bad connection');
console.log(data);
}
});
After trying this, I noticed that the {%for%} from the third div 'WpisChild' is displayed as text instead of being processed by the function. Can you explain why this is happening?