Reputation: 23
I am trying to render the template called reset_password_page.html using AJAX. I intend to send some data to this template. The problem is that page is not getting loaded. It gets loaded when I use location.href, but this cannot be used as I won't be able to send any data to the template.
function trial() {
if ("{{ verified }}" == "yes") {
document.getElementById('lbl_verify').style.display = "block";
document.getElementById('lbl_verify2').style.display = "none";
window.setTimeout(function() {
$(document).ready(function() {
$.ajax({
url: "{% url 'reset_password_page' %}",
type: "POST",
data: {
csrfmiddlewaretoken: '{{ csrf_token }}'
},
async: false,
});
});
}, 1000);
} else {
}
}
views.py
def reset_password_page(request):
return render(request,"reset_password_page.html")
Upvotes: 0
Views: 55
Reputation: 575
Its due to the if condition used.You are comparing if ("{{ verified }}" == "yes") which is false. try if ({{ verified }} == "yes") which will fetch verified value.
Upvotes: 1