return render(request, 'index.html', {"flag": flag, "form": form})
I want to pass flag value which should be read by javascript to change style of an element in template, but since rendering it again the flag value is lost and set back to "none" ,is there any way to not use render and pass the variable to a url where the page is already rendered
$.ajax({
type: "GET",
url: "/home", //url of site no need to enter full site
dataType: "json",
contentType: 'application/json',
success: function (response) {
alert(response.flag);
// Gives value of flag
},
error: function (response) {
alert('error');
}
});
update : i tried this code but it always goes into error session and doesnt get into success block