Image flashes in Chrome

0

I load a PHP file that brings me an image in jpg. Code:

<?php
$url = "http://site.com.br/sistema/";
?>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

<script type="text/javascript">
var auto_refresh = setInterval(
function ()
{
$('#load_tweets').load('arquivo.php').fadeIn("slow");
}, 1000); // refresh every 10000 milliseconds
</script>

<div id="load_tweets">
</div>

file.php looks like this:

<?php
$conecta = mysql_connect('localhost','teste','teste')or die(mysql_error());
$banco = mysql_select_db('nomeBanco');

$selecionaTabela = mysql_query("SELECT * FROM noticias WHERE id = '187'")or die(mysql_error());
$dados = mysql_fetch_array($selecionaTabela);
?>

<img src="modulos/upload/<?php echo $dados['fotoEvento'];?>" alt=""/>

But in Chrome the image is blinking, not in Mozilla anymore!

    
asked by anonymous 14.05.2014 / 15:49

1 answer

0
  

In any case, do not replace the entire contents of the #load_tweets div once a second. Search only for new content, and insert at the end of the div if any.

I do not know exactly what the purpose of your application is, but the most common one is exactly what bfavaretto said: display only new content. To do this:

1) Whenever new content is inserted into the database, enter insert date .

2) At each access to the ".php file" record in the user session the access date / time .

Information 1 and 2 will let you know when the content was entered and the last time the user uploaded the content. All you have to do is check only content that has a longer insertion date than the date the user last uploaded the content.

Ex:

$ultimaVisita = empty($_SESSION['ultimaVisita'])?'0000-00-00 00:00:00':$_SESSION['ultimaVisita'];


$selecionaTabela = mysql_query("SELECT * FROM noticias WHERE id = '187' AND data_insersao > '".$ultimaVisita."'")or die(mysql_error());
$dados = mysql_fetch_array($selecionaTabela);

$_SESSION['ultimaVisita'] = Date('Y-m-d H:i:s');
    
14.05.2014 / 23:35