1
Hello, I have a small project just for Hobbie, and I have some Datatables on my web page, to facilitate the search of registered data, but when I register any data in a Brownser tab, the other one does not appear unless I give a refresh/Reload/F5 on the page, how would I automate this "refresh"?
<div class="tab-pane" id="tab7">
<div class="content-box-large">
<div class="panel-heading">
<div class="panel-title">Área de Serviço</div>
<div class="panel-options">
<a href="#" data-rel="collapse"><i class="glyphicon glyphicon-refresh"></i></a>
</div>
</div>
<div class="panel-body panel-refresh" id="refresh4">
<div class="refresh-data">
<table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="example4">
<thead>
<tr>
<th>Código</th>
<th>Área de Serviço</th>
</tr>
</thead>
<tbody>
<?php
$consultar_area_servico = "SELECT * FROM `$tabela_area_servico`";
$resultado_consultar_area_servico = mysql_query($consultar_area_servico);
$quantidade_resultado_area_servico = mysql_num_rows($resultado_consultar_area_servico);
for($i = 0;$i < $quantidade_resultado_area_servico; $i++)
{
$vetor_area_servico = mysql_fetch_array($resultado_consultar_area_servico);
?>
<tr class="gradeA">
<td><button type="button" class="btn btn-default btn-block btn-xs" data-toggle="modal" data-target="#myModalAS<?php echo $vetor_area_servico['codigo'];?>"><?php echo $vetor_area_servico['codigo']; ?></button></td>
<td><input class="form-control" type="text" name="c_area_servico" value="<?php echo $vetor_area_servico['area_servico']; ?>"></td>
</tr>
<div class="modal fade" id="myModalAS<?php echo $vetor_area_servico['codigo'];?>" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<form action="web/acoes.php" method="post">
<input type="hidden" name="confirma" value="8">
<input type="hidden" name="c_cod" value="<?php echo $vetor_area_servico['codigo'];?>">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">#<?php echo $vetor_area_servico['codigo'];?></h4>
</div>
<div class="modal-body">
<p>Área de Serviço:<input class="form-control" type="text" name="c_area_servico" value="<?php echo $vetor_area_servico['area_servico']; ?>"></p>
<center>
<button type="submit" name="button" value="1" class="btn btn-danger btn-sm">Excluir</button>
<button type="submit" name="button" value="2" class="btn btn-success btn-sm">Alterar</button>
</center>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Fechar</button>
</div>
</form>
</div>
</div>
</div>
<?php
}
?>
</tbody>
</table>
</div>
</div>
</div>
Update only the entire page or div ?
– Vinicius Shiguemori
mysql is obsolete in recent versions of php, use mysqli.
– Francisco
A better solution than a refresh (although much more laborious) is to make an ajax request of X in X time and change the page based on what you receive in that request
– Isac
I wanted to update all Divs that have a Datatable, but unfortunately it will not be possible to escape from Ajax ;-;
– Rafael Breno
You have to make an Ajax, as you put in the tags yourself.
– Sam