0
I’m trying to pass the cod_historico
via jQuery, inside a button, which will open a modal, to search internal views of a 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 historical cod_from the button, with 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?
The first line of your jQuery seems to be repeated. That’s right?
– Waldir J. Pereira Junior
in its third line Voce is looking for
#cod_historico
, this is aid
. where is theid
from your button? and another should not repeat ids & #Xa;put a class for examplemeu_btn
and instead of calling$("#cod_historico")
. vc calls$(".meu_btn")
.– Jasar Orion
It’s on the historical date-cod_historical, the id
– Sr. André Baill