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);
}
});
}
});
});