EDITED
I am trying to send the following data with AJAX
var datosInsert = JSON.stringify({
'datosCarga': valoresEntrada, //[1,2,3]
'loteCaja': fieldLote, //101
'cajaLote': numeroCaja //1
});
$.ajax({
url: "views/ajax/OITSave.php",
method: "POST",
data: datosInsert,
async: false,
cache: false,
contentType: false,
processData: false,
//dataType: "json",
success: function(respuesta) {
console.log("Se devolvio: ", respuesta);
}
});
I am receiving them and "assigning" them in the following way to the file where I direct the ajax
<?php
require_once "../../controllers/OIT.php";
require_once "../../models/OIT.php";
#CLASES
#**********************************************************************
class Ajax{
#RECIBE DATOS PARA INGRESO CAJA
public $loteIngreso;
public $cajaIngreso;
public $recorrido;
public $valoresCaja=[];
public function agregarEnCaja(){
echo $loteIngreso;
}
}
#OBJETOS
#************************************************************************
if(isset($_POST['loteCaja'])){
$c = new Ajax();
$c -> loteIngreso = $_POST['loteCaja'];
$c -> cajaIngreso = $_POST['cajaLote'];
$c -> valoresCaja = $_POST['datosCarga'];
$c -> agregarEnCaja();
}
?>
But when I execute it, the answer is empty. Is the way you send the data okay? If so, is the way I receive the data okay?
Really, thank you very much for the help.