Pass variable $ _GET from Ajax to the controller

0

I have this function:

public function GestorGaleriaOperadorCafe(){

    $datos=$this->imagenTemporal;
    $id=$_GET['id'];
    $respuesta=controllerOperadorCafes::mostrarImagenOfertasController($datos,$id);
     echo $respuesta;

     }

With that function I receive data by ajax, I pass the data to the controller , if I try to receive the variable directly by the controller, it does not work for me

public function mostrarImagenOfertasController($datos,$id){



        $datosController=array("ruta"=>$ruta,
                                "id"=>$id);

        DatosOperadorCafe::subirImagenOfertasgaleriaModel($datosController,"galeria_ofertas_cafe");
        $respuesta=DatosTienda::mostrarImagenOfertasgaleriaModel($datosController,"galeria_ofertas_cafe");

        echo $respuesta['ruta'];

    }
    
asked by jorgnv 28.08.2017 в 19:33
source

2 answers

0

If you are not using any route interceptor and / or framework, the only way to receive the parameters of a requisition in php is through $ _GET []. Do you use any framework?

    
answered by 28.08.2017 в 19:39
0

so I see the variables $id and $ruta are local to the function, I think you need to use the $this

$this->datos=$this->imagenTemporal;
$this->id=$_GET['id'];

/*******/

$datosController=array("ruta"=>$this->ruta,
                            "id"=>$this->id);
  

Do not forget to create the global variables

    
answered by 28.08.2017 в 19:47