[Answer]-Django getlist() from ajax html form

1👍

You’re not giving a key value pair to the data argument, but you shouldn’t even have to go that far – you don’t have to gather the checkbox values yourself. You can replace this:

    var myCheckboxes = new Array();
    $("input:checked").each(function() {
       myCheckboxes.push($(this).val());
    });

    $.ajax({
        type: "POST",
        url: 'django/builder/buildit',
        data: myCheckboxes,
        success: function(response){
            alert(response);
        }
    });

With this, using serialize:

    $.ajax({
        type: "POST",
        url: 'django/builder/buildit',
        data: $('#myform').serialize(),
        success: function(response){
            alert(response);
        }
    });

Leave a comment