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

224
Views
Retrieving data without refreshing the page with ajax in django

I can post with ajax, but when I want to pull data without refreshing the page, I can only do it 2 times, then the button loses its function.

<div>
  <input type="hidden" name="producecode" class="pcode" value="{{per.produceCode}}" />
  <input type="hidden" name="useremail" class="uponequantity" value="{{user.username}}" />
  <button class="btn btn-sm btn-primary upoq"><i class="fa fa-plus"></i></button>
</div>

and jquery

$(".upoq").on("click", function() {
  $(".uponequantity").attr("value", localStorage.getItem('key'));
  var producecode = $(this).parent().find(".pcode").val();

  $.ajax({
    type: "POST",
    url: "/uponequantity/",
    headers: {
      "X-CSRFToken": '{{csrf_token}}'
    },
    data: {
      "producecode": $(this).parent().find(".pcode").val(),
      "useremail": $(".uponequantity").val(),
    },
    success: function() {
      //window.location.assign('/basket/'+"?b="+$(".uponequantity").val());
      $.ajax({
        url: '/basket/' + "?b=" + $(".uponequantity").val(),
        headers: {
          "X-CSRFToken": '{{csrf_token}}'
        },
        type: 'POST',
        success: function(result) {
          $('.basket').html(result);
        }
      });
    }
  });
});
about 4 years ago · Juan Pablo Isaza
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!