-2

dd = [ [2,3], [4], [2], [1,2,3] ]

for i in dd:

if len(i)==1:
    dd.remove(i)
    print(dd)
else:
    pass

print(dd)

2 Answers2

0

Your AJAX call is incorrect.

You are passing an object which has a property called column_name which contains a literal string "sortOrder".

Try something like this:

function sortby(selectObject) {
    var sortOrder = selectObject.value;
    $.ajax({
        url: "sort.php",
        method: "POST",
        data: { column_name: sortOrder },
        success: function(data) {
            $('#allProducts').html(data);
        }
    })
    console.log("called");
}

And then in PHP:

<?php
if(isset($_POST['column_name']) {
    // do something here
} else {
    echo 'No value was passed!';
}
Dharman
  • 26,923
  • 21
  • 73
  • 125
0

You have to make following changes in your data object.

function sortby(selectObject) {
        var sortOrder = selectObject.value;
        $.ajax({
            url: "sort.php",
            method: "POST",
            data: { "sortOrder": sortOrder }, // the var you have get from DOM to sent to PHP code
            success: function(data) {
                $('#allProducts').html(data);
            }
        })
        console.log("called");
    }

sorOrder indes is looked into $_POST[] array but it can't found and hence it return you notice.

Vantiya
  • 582
  • 1
  • 3
  • 10