All screen transitions, when I need to call a variable data, have this problem. Always return the vector as empty.
As long as the transitions are made with value defined, for example: $_POST ['vaga'] = ['2']
, the vector is returned with all its variables (40)
without error in form html
.
But the problem is that the value quoted in the example ['2']
must be variable, since it must be assigned from another list. The relationship is:
page 1 - list of vacancies with 5 main variables and 1 button to present the details of the vacancy;
page 2 - details of the job selected in the button on page 1;
The code that works, with the fixed variable is:
include_once('class_vaga.php');
$obj = new class_vaga();
$obj->host = '127.0.0.1';
$obj->username = 'root';
$obj->password = '';
$obj->table = 'vaga';
$obj->connect();
$_POST ['vaga'] = ['2'];
$return = json_decode($obj->ajaxCall('load_detalhes_vagas',array($_POST['vaga'][0])));
var_dump($return);
?>
When I try to make it vary according to the button clicked, the problem comes. I noticed that this happens on all other pages (login, graphics, etc), because whenever I use a fixed number the system accepts, at the time of making it variable the thing hangs.
Code that does not work:
include_once('class_vaga.php');
$obj = new class_vaga();
$obj->host = '127.0.0.1';
$obj->username = 'root';
$obj->password = '';
$obj->table = 'vaga';
$obj->connect();
$id_vaga = ' ';
foreach ($_POST as $key => $value) {
if($key == "action"){
$action = $value;
}else{
$id_vaga = $value;
}
}
$return = json_decode($obj->ajaxCall('load_detalhes_vagas',array($id_vaga)));
var_dump($return);
?>
The call function on page 2 is:
function loaddetalhes(idVaga){
$.ajax({
type: "POST",
url: 'http://localhost/workspace/detalhes_vaga.php',
data: { action: 'load_detalhes_vagas', vaga: idVaga },
dataType: "json",
complete: function (data){
window.open('detalhes_vaga.php');
},
});
}