$(document).ready(function(){ setTimeout('refresh_div()', 2000); });
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionalert('sa passe')
<code php><div id="chat" style="position:absolute; top:200px"> <?php include("Menu_page_defilant/page_defilante.php"); ?> </div></code>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script> function refresh_div() { var xhr_object = null; if(window.XMLHttpRequest) { // Firefox xhr_object = new XMLHttpRequest(); } else if(window.ActiveXObject) { // Internet Explorer xhr_object = new ActiveXObject('Microsoft.XMLHTTP'); } var method = 'GET'; var filename = 'page.php'; xhr_object.open(method, filename, true); xhr_object.onreadystatechange = function() { if(xhr_object.readyState == 4) { var tmp = xhr_object.responseText; document.getElementById('chat').innerHTML = tmp; } } xhr_object.send(null); } setTimeout('refresh_div()', 2000);
il m'affiche dans la partie ou doit s'afficher page.php :... tu as une erreur dans ta page PHP...
No database selected
<?php include("../functions/connect.php"); <?php
il y a plus d'erreur qui s'affiche mais j'ai l'impression qu'il n as pas de refraichissement
<div id="chat" style="position:absolute; top:200px"> <?php include("Menu_page_defilant/page_defilante.php"); ?> </div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script> function refresh_div() { var xhr_object = null; if(window.XMLHttpRequest) { // Firefox xhr_object = new XMLHttpRequest(); } else if(window.ActiveXObject) { // Internet Explorer xhr_object = new ActiveXObject('Microsoft.XMLHTTP'); } var method = 'GET'; var filename = 'Menu_page_defilant/page_defilante.php'; xhr_object.open(method, filename, true); xhr_object.onreadystatechange = function() { if(xhr_object.readyState == 4) { var tmp = xhr_object.responseText; document.getElementById('chat').innerHTML = tmp; } } xhr_object.send(null); } alert('sa passe'); </script>
$(document).ready(function(){ setInterval('refresh_div()', 2000); });
<script> function refresh_div() { var xhr_object = null; if(window.XMLHttpRequest) { // Firefox xhr_object = new XMLHttpRequest(); } else if(window.ActiveXObject) { // Internet Explorer xhr_object = new ActiveXObject('Microsoft.XMLHTTP'); } var method = 'GET'; var filename = 'Menu_page_defilant/page_defilante.php'; xhr_object.open(method, filename, true); xhr_object.onreadystatechange = function() { if(xhr_object.readyState == 4) { var tmp = xhr_object.responseText; alert(tmp) document.getElementById('chat').innerHTML = tmp; setTimeout(refresh_div, 2000); } } xhr_object.send(null); } </script> typeof window.addEventListener == 'undefined' ? attachEvent("onload",function(){setTimeout(refresh_div, 2000);}) : addEventListener("load",function(){setTimeout(refresh_div, 2000);}, false);
<html> <head> <title> Test TimeOut</title> </head> <body> Test d'utilisation d'un timer.. <div id="maDiv"> </div> <script type="text/javascript"> function maZoliFunc(){ var oDiv = document.getElementById("maDiv"); var ctn = oDiv.innerHTML; var today = new Date(); var now = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds(); oDiv.innerHTML = ctn + now + " Ajout de données...<br> " } // Initialisation du timer... typeof window.addEventListener == 'undefined' ? attachEvent("onload",function(){setInterval(maZoliFunc, 2000);}) : addEventListener("load",function(){setInterval(maZoliFunc, 2000);}, false); </script> </body> </html>
<script type="text/javascript"> function maZoliFunc(){ var oDiv = document.getElementById("maDiv"); var ctn = oDiv.innerHTML; var today = new Date(); var now = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds(); oDiv.innerHTML = ctn + now + " Ajout de données...<br> " setTimeout(maZoliFunc, 2000); } // Initialisation du timer... typeof window.addEventListener == 'undefined' ? attachEvent("onload",function(){setTimeout(maZoliFunc, 2000);}) : addEventListener("load",function(){setTimeout(maZoliFunc, 2000);}, false); </script>
xhr_object.onreadystatechange = function() { if(xhr_object.readyState == 4) { var tmp = xhr_object.responseText; alert(tmp) document.getElementById('chat').innerHTML = tmp; setTimeout(refresh_div, 2000); } }