My view:
$('#frm_ingreso').submit(function(e) {
$.ajax({
url: `${RUTA}retaso-ingreso/guardar`,
type: 'POST',
data: {
"data": $('#frm_ingreso').serialize()
},
})
.done((response) => {
console.log(response);
});
e.preventDefault();
return false;
});
My Controller:
I show all post with print_r($_POST)
and it´s shown, but when I want to pass variable each data:
public function guardar(){
print_r($_POST);
/*
Array
(
[data] =>
cboMaterial=2&cboTipo=3&cboColor=2
)
*/
$material = $this->input->post("cboMaterial"); // error it's show nothing
echo $material; // its show nothing
}
You should do this:
data: $('#frm_ingreso').serialize()
Usage:
$('#frm_ingreso').submit(function(e) {
$.ajax({
url: `${RUTA}retaso-ingreso/guardar`,
type: 'POST',
data: $('#frm_ingreso').serialize(),
})
.done((response) => {
console.log(response);
});
e.preventDefault();
return false;
});
and $material = $this->input->post("cboMaterial");
should work
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.