I'm trying to pass cod_historico
via jQuery, within a button, which I'll open a modal, to search for internal views of specific content.
I'm generating a list coming with database records:
<tbody>
<?
$i = 0;
foreach($interessados as $valor){
?>
<tr role="row">
<td><? echo $valor->int_nome; ?></td>
<? if($this->session->userdata['con_cod_tipo']=='2'){ ?>
<td><? echo $valor->int_cod_unidade; ?></td>
<? } ?>
<td><? echo $valor->int_cod_consultora; ?></td>
<td><? echo $valor->int_cod_curso; ?></td>
<td><? echo $valor->int_cod_campanha; ?></td>
<td><? echo date("d/m/Y H:i:s", strtotime($valor->int_data)); ?></td>
<td><? echo $valor->int_status; ?></td>
<td style="width: 12%">
<div class="btn-group">
<a>
<button type="button" class="btn btn-danger btn-custom" name="visualizar" data-toggle="modal" data-target="#visualiza-historico" data-cod_historico="<? echo $valor->int_cod; ?>"><i class="fa fa-history"></i></button>
</a>
<a href="<? echo base_url("index.php/interessado/editar/".$valor->int_cod); ?>">
<button type="button" class="btn btn-warning btn-custom"><i class="fa fa-edit"></i></button>
</a>
<? if($this->session->userdata['con_cod_tipo']=='2'){ ?>
<a>
<button type="button" class="btn btn-danger btn-custom" name="deletar" data-toggle="modal" data-target="#confirma-deletar" data-href="<? echo base_url("index.php/interessado/deletar/".$valor->int_cod); ?>"><i class="fa fa-trash"></i></button>
</a>
<? } ?>
</div>
</td>
</tr>
<? $i++; } ?>
</tbody>
And I'm using this jQuery to fetch the button's historical_code, with the alert:
$('#visualiza-historico').on('show.bs.modal', function(e) {
$("#cod_historico").val($(this).data('cod_historico'));
alert(cod_historico);
var url = "<? echo base_url("index.php/interessado/historico/"); ?>/" + $("#cod_historico").val() ;
$('#div_historico_prospects').html("<div><center><img src='<? echo base_url("themes/default/dist/img") ?>/loading_anim.gif'><br><br><strong>Por favor, aguarde que estamos buscando o histórico...</strong></center></div>");
setTimeout(function(){
$('#div_historico_prospects').load(url);
},5000);
});
Where am I going wrong?