Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

461
Views
cómo mostrar el mensaje de éxito sin actualizar la página en django

Tengo una plantilla llamada canasta cada vez que quiero actualizar la cantidad del producto, funciona bien, pero el mensaje de éxito no aparece hasta que actualizo la página.

ingrese la descripción de la imagen aquí

vistas.py:

 def basket_update(request): basket = Basket(request) if request.POST.get('action') == 'post': book_id = int(request.POST.get('bookid')) book_qty = int(request.POST.get('bookqty')) basket.update(book=book_id, qty=book_qty) messages.success(request,"Basket Has Been Updated") basketqty = basket.__len__() baskettotal = basket.get_total_price() response = JsonResponse({'qty': basketqty, 'subtotal': baskettotal}) return response

ajax:

 $(document).on('click', '.update-button', function (e) { e.preventDefault(); var book_id = $(this).data('index'); $.ajax({ type: 'POST', url: '{% url "basket:basket_update" %}', data: { bookid: $(this).data('index'), bookqty: $('#select' + book_id + ' option:selected').text(), csrfmiddlewaretoken: "{{csrf_token}}", action: 'post' }, success: function (json) { document.getElementById("basket-qty").innerHTML = json.qty document.getElementById("subtotal").innerHTML = json.subtotal }, error: function (xhr, errmsg, err) {} }); })
over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!