1
I need help making a forward and back button for a birthday list. The data will be sent via POST to a query class. The PHP
is ok. I need to adapt the JavaScript
.
PHP
$data = date('Y-m-d');
$data_explode = explode("-", $data);
$dia = $data_explode[2];
$mes = $data_explode[1];
$ano = $data_explode[0];
$v_mes = substr($mes, 0, 2); //voltar mes
$novo_mes = (int) $mes - 1; //avancar mes
$botoes_mes = '<div class="medium-2 columns float-left">
<a id="#action-aniver" rel="' . $v_mes . '"><i class="fi-arrow-left"></i></a></div>
<div class="medium-8 columns float-center">
<h4 class="text-center">' . $mes . '</h4>
</div>
<div class="medium-2 columns">
<a id="#action-aniver" rel="' . $novo_mes . '"><i class="fi-arrow-right float-right"></i></a>
</div>';
Ajax class:
case 'aniversario':
$char = $_POST['val'];
$body = '';
$dados = connection::select("SELECT * from aniversarios where MONTH(data_usuario) = '" . $char . "'");
foreach ($dados as $reg) {
$body .= '<p>' . $reg['nome'] . '</p>';
}
retorno = $body;
break;
Javascript
$('#action-aniver').click(function () {
var chars = (this.value);
$.post(URL + 'Ajax/aniversario', {val: chars}, function (busca) {
$('#aniver-ajax').html(busca);
});
});
What’s the problem you’re having?
– BrTkCa
The code doesn’t work. I actually tried to do it. But I couldn’t. I believe the problem is in the javascript function
– Eduardo Santos