I have the javascript below that gets all checked box and it works well.
<script>
function addlist() {
var array = []
var checkboxes = document.querySelectorAll('input[type=checkbox]:checked')
for (var i = 0; i < checkboxes.length; i++) {
array.push(checkboxes[i].value);
}
}
</script>
I want to know how to submit the list array to views.py and get it via request.POST['']
Any suggestions?
document.writeinstead of sending a request to the server withfetchor similar. Before trying to POST an array, you might as well set up POSTing non-array data, then figure out the step to encode an array as form data. As it stands, none of the code shown has anything to do with Django or AJAX.