Bonjour à tous,

Alors voilà j'utilise Ajax pour afficher des citations sur mon site aléatoirement et sans rafraichissement complet de la page => utilisation de Ajax.
Les citations proviennent d'une base de données.

Mon soucis pour le moment est que lors du changement de citation, le div qui les contient clignote une fraction de seconde avant le changement.
Je ne sais pas à quoi c'est du mais je trouve cela assez embettant,...

Voir ici

Voici mon script, peut-être saurez vous me dire ce qui provoque cela :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
 
<?php 
$con = mysql_connect("localhost", "xxxxx", "xxxxx");
mysql_select_db("xxxxx", $con);
$row = mysql_fetch_array(mysql_query("SELECT * FROM we_quotes order by rand() limit 1"));
mysql_close($con);
echo "<img src=".htmlentities($row[2])." style=\"width:80px; height:80px; float:left; margin:0 8px 5px 0;\"/>";
echo "&laquo; " . htmlentities($row[1]) . " &raquo;";
?>
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
 
// Customise those settings
 
var seconds = 5;
var divid = "quotes";
var url = "quotes.php";
 
function refreshdiv(){
 
// The XMLHttpRequest object
 
var xmlHttp;
try{
xmlHttp=new XMLHttpRequest(); // Firefox, Opera 8.0+, Safari
}
catch (e){
try{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); // Internet Explorer
}
catch (e){
try{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){
alert("Your browser does not support AJAX.");
return false;
}
}
}
 
// Timestamp for preventing IE caching the GET request
 
fetch_unix_timestamp = function()
{
return parseInt(new Date().getTime().toString().substring(0, 10))
}
 
var timestamp = fetch_unix_timestamp();
var nocacheurl = url+"?t="+timestamp;
 
// The code...
 
xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState==4){
document.getElementById(divid).innerHTML=xmlHttp.responseText;
setTimeout('refreshdiv()',seconds*1000);
}
}
xmlHttp.open("GET",nocacheurl,true);
xmlHttp.send(null);
}
 
// Start the refreshing process
 
var seconds;
window.onload = function startrefresh(){
setTimeout('refreshdiv()',seconds*1000);
}
Un grand merci !