[Fixed]-How to send 2 json array via ajax to view in django

1👍

Please include both situations in One ajax post request and send it to your view.The mistake you are doing here is that you are sending two different requests.

    var jsonArrLeft = [];
    var jsonArrRight = [];
    $('#btnSave').on('click', function () {
        $('.form-group right').each(function () {
            debugger;
            value = $(this).find("input[name='ValueRight']").val()
            label = $(this).find("input[name='LabelRight']").val()
            jsonArrRight.push({
                label: label,
                value: value
            })
        $('.form-group left').each(function () {
            value = $(this).find("input[name='ValueLeft']").val()
            label = $(this).find("input[name='LabelLeft']").val()
            jsonArr.push({
              label: label,
              value: value
           })
            var   jsonLeft = JSON.stringify(jsonArrLeft);
            var jsonRight = JSON.stringify(jsonArrRight);
            $.ajax({
                url: '{% url 'add_label_value' %}',
                method: 'POST',
                dataType: 'JSON',
                data: {
                    'csrfmiddlewaretoken':  $('input[name="csrfmiddlewaretoken"]').val(),
                    'jsonRight ': jsonRight ,
                    'jsonLeft': jsonLeft      


},
            success: function (data) {
                alert(data);
            }
        });
    })

Leave a comment