For what reason I can not receive the value commerce_brand by post in the following algorithm

0

What I want to do is to receive the value of the variable column in the route that I specify by ajax

$(document).ready(function(){
//alert("hola");
let selectCards =$('#cards');  
let selectEstados =  $('#estados');
let columna = 'commerce_brand';
//let selectCards = document.querySelector('#cards');

function cargarOpciones (idSelectIndependiente, columna, idSelectDependiente){
console.log(idSelectIndependiente); 
console.log("entrando");
console.log(columna);
 $.ajax({
        type:'POST',
        url: 'cargar_estados.php',
        data:{ 
                'peticion': 'idSelectIndependiente',
                'num':'columna'
            }
    })
    .done(function(lista_rep1){

        console.log(lista_rep1);

        idSelectIndependiente.empty();
        idSelectIndependiente.append('<option value="">Elige una opcion</option>');
        for (var i = 0; i < lista_rep1.length; i++) {

          idSelectIndependiente.append("<option value='lista_rep1[i][commerce_brand]'>lista_rep1[i][commerce_brand]</option>");
        //idSelectIndependiente.append('<option value="'+lista_rep1[i]['id']+'">'+lista_rep1[i][1]+'</option>');

    };            

    })
    .fail(function(){
        alert('error al cargar las listas');
    });
console.log("saliendo");
}

Here is where the value of that variable should arrive and be captured in another variable.     

$cards = $POST_['peticion'];
$columna =$POST_['num'];




function getData($idSelect = false, $columna){

    switch ($columna){
        case 'commerce_brand':
            $con = getCon();
            $query = "SELECT commerce_brand FROM 'commerc' group by commerce_brand";
            $result = $con->query($query);
            return $result;
        break;

        default:
        $probando = "viene por defecto";
        return $probando;
    }
}

echo getData($cards,$columna);
    
asked by javier 29.10.2018 в 22:01
source

0 answers