I have 2 images, the idea is that when I click on one of them, I save the associated category in a session variable. I searched for information and tried with ajax, but mysteriously it returns ... code ... not the variable, that is ... something is wrong. The code : File manage.php
function modificarValor(valor){
var url = 'b_categoria.php';
$.ajax({
type: 'POST',
url: url,
data: {valor},
success:function(data){
console.log("Valor Variable : "+ data);
}
});
}
<div class="marco_central2">
<div style="float:left;padding:10px;padding-top:184px;">
<a href="/ACCE/adelante" class="reload_link" onclick="modificarValor(1)">
<?php echo $this->Html->image('menu/HIT-CATEGORIA-2.png'); ?></a>
</div>
<div style="float:right;padding:10px;padding-top:184px;">
<a href="/ELEC/adelante" class="reload_link" onclick="modificarValor(2)">
<?php echo $this->Html->image('menu/HIT-CATEGORIA-1.png'); ?></a>
</div>
</div>
b_categoria.php file
<?php
$valor = $_POST['valor'];
session_start();
switch ($valor) {
case 1:
$_SESSION['categoria_actual'] = "accesorios";
echo 'Accesorios';
break;
case 2:
$_SESSION['categoria_actual'] = "servicios";
echo 'Servicios';
break;
}
?>
I clarify that it is an application made in cakephp 1.3 very old, that developed in the place where I work .. and there are some php encrypted, the developers disappeared years ago. I will appreciate any help!