I am making a sales module and with a button I go to the list of clients. When you click on a row in the table, in the AJAX request I want to call the index and pass the idcliente as a parameter to consult it in the ready. Because I don't want to use sessions because it's not a sales cart, it's a spontaneous sale in a store.
$('#clientes tbody').on('click','tr', function(evt){
$(this).find('input:radio').prop('checked', true);
var idc= $('input:radio[name=seleccion]:checked').attr("id");
alert(idc);
var accion = 'asociar';
$.ajax({
type: "POST",
data: {"idc":idc,"accion":accion},
error: function(){
alert("error petición ajax");
},
success: function(data){
window.location.href ="index.php?controller=venta&action=index?id=".idc;
}
});
}); });
I use the model view controller. If I pass a fixed number inside the string it works perfectly... but not with the variable.
I see the problem is how you build the URL, before id you should put an &, also the concatenation in JavaScript should be done with a +, that is, it should be like this:
In any case, I don't know if it is best to pass the ID through the URL, because any user could change it.
I hope it helps you.
Luck!