We used AJAX to launch a POST request with a set of data. We noticed that a piece of data was being sent incorrectly. After fixing it, we sent the request again but the web where we display the data is not updated, despite having checked that the request sends the data correctly. Could someone tell me how can I fix it please?
This is my code:
//ajax function to send graphs to backend
$(document).ready(async function(){
await new Promise(r => setTimeout(r, 1500));
var canvas_elements=document.getElementsByClassName("chartjs-render-monitor")
if (canvas_elements.length==2) {
$('#bar-chart').addClass(function(){
const csrf_cookie=getCookie('csrftoken');
$.ajax({
url: "graphs/",
type: "POST",
data:{
type:$('#vot_type').val(),
graphs:graphs_images(),
},
beforeSend: function(xhr) {
xhr.setRequestHeader("X-CSRFToken", csrf_cookie)
},
failure: function(data){
console.log(error)
}
}).done(function(response){
console.log("Hecho")
});
});
}
});
We checked the console to see if the data was sent correctly, and as we can see, it sends the type and url of the graphs. console
But when we check the web, it is not updated.
Thank you so much in advance!