I am generating a table by divs, some filters with some selects. At the moment I can decide how many records I want to show, but I have to send more variables, for example the select that I ordered by price. I show the AJAX that I have, if someone knows how to send more than one variable. Thanks
$(function(){
$("#registros, #ordenar, #tipo").on("change", function(e){
var registros ="";
var ordenar ="";
var tipo ="";
if ($("#registros").val() !=null){
registros = $("#registros").val();
}
if ($("#ordenar").val() !=null){
ordenar = $("#ordenar").val();
}
if ($("#tipo").val() !=null){
tipo = $("#tipo").val();
}
$.ajax({
url: "filtros.php",
type: "post",
dataType: "html",
data: {
'registros': registros,
'ordenar': ordenar,
'tipo': tipo
},
beforeSend: function(){
$("#res").html("Procesando, espere por favor...")
},
success: function (resultado){
$("#res").html(resultado);
}
});
});
});
Then in the other file that generates the query is like this.
$results = $mysqli->query("SELECT productos.id, productos.producto,
productos.imagen, productos.alias, posibles.idproducto, posibles.tipo,
posibles.entrada, posibles.mensualidad, posibles.final, posibles.total
FROM productos, posibles WHERE productos.id = posibles.idproducto AND
posibles.tipo =" . $_POST["tipo"]. " ORDER BY posibles.final $orden
$limit");