Answer the question
In order to leave comments, you need to log in
Why is the data not updated via AJAX request?
I need a dynamic content update on the personal account page. Namely div'a with class and id start.
views.py file:
def orders_update(request):
if request.is_ajax():
temp_point_uid = request.POST['point_uid']
if point.objects.filter(uid_point=temp_point_uid).exists():
orders_count = order.objects.filter(point_id=temp_point_uid)
context = {
'orders_count': orders_count
}
print("updated")
return render(request, 'lk_point.html', context)
else:
return Http404
return HttpResponse()
function load_orders() {
$.ajax({
url: "{% url 'orders_update' %}",
type: "POST",
data: {'point_uid': {{ point_uid }}, 'csrfmiddlewaretoken' : "{{csrf_token}}"},
success: function () {
alert('updated');
$('#start').load;
}
});
};
setInterval(load_orders, 10000);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question