Why I can’t get value from Jquery to php?
I’m trying to make a dynamic Combobox in PHP and jquery, but can’t use the data of the post
Jquery
$(document).ready(function(){
var cambio = $('#categoria');
categoria1 = $(cambio).val();
console.log(categoria1);
$.post('agregar_productos.php',{categoria1:categoria1},function(){
});
})
My PHP code
I tried also this:
$.ajax({
url:'agregar_productos.php',
method:"POST",
data:{categoria1:categoria1},
success:function(){
}
})