Rapha222  | Salut,   Je suis en train d'essayer ajax et j'ai un gros problème : php ne revoie rien au navigateur, même pas les balises HTML (voir cette page)
   Voici mon code :
  Code :
 - <?php
 -         require('../includes/config.php');
 -         // On se connecte a la base de données
 -         mysql_connect($config->db_host, $config->db_user, $config->db_password);
 -         mysql_select_db($config->db_name);
 -         // On fait une requete à la BDD si c'est le module de MAP pour avoir les informations du miniplofil
 -         $retour = mysql_query('SELECT * FROM "phpore_users" WHERE id = "'.$_GET['id'].'" and password = "'.$_GET['pass'].'"');
 -         $miniprofil = mysql_fetch_array($retour);
 -         // On prépare xajax et on enregistre les fonctions  
 -                
 -         function goldards() // Fonction qui affiche les nombre d'argent  
 -         {
 -                 $reponse = new xajaxResponse();
 -                 $goldards = '<span class="goldard">'.$miniprofil['goldard'].'</span><img src="../img/goldard.png" />';
 -                 $reponse->addAssign("goldards","innerHTML",$goldards);
 -                 return $reponse->getXML();
 -         }
 -        
 -         function hp() // Fonction qui affiche le nombre de HP et calcule un tableau qui la représente
 -         {
 -                 $reponse = new xajaxResponse();
 -                 $hp_on = $miniprofil['hp_max'] / $miniprofil['hp'];
 -                 $hp_on = floor($hp_on * 75);
 -                 $hp_off = 150 - $hp_on;
 -                 $hp = '<table width="280" border="0" cellpadding="0" cellspacing="0">
 -             <tr>
 -         <td width="35">HP : </td>
 -         <td width="'.$hp_on.'" background="templates/default/images/hp_on.png"></td>
 -         <td width="'.$hp_off.'" background="templates/default/images/hp_off.png"></td>
 -         <td width="95" align="right">'.$miniprofil['hp'].'/'.$miniprofil['hp_max'].'</td>
 -         </tr></table>';
 -         $reponse->addAssign("hp","innerHTML",$hp);
 -         return $reponse->getXML();
 -         }
 - require ('../xajax_0.2.4/xajax.inc.php');
 - $xajax = new xajax();
 - $xajax->registerFunction("goldards" );
 - $xajax->registerFunction("hp" );
 - $xajax->processRequests();
 - ?>
 - <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 - <html xmlns="http://www.w3.org/1999/xhtml">
 - <head>
 - <script type="text/javascript">
 - <!--
 - // <![CDATA[
 - function correctPNG() // correctly handle PNG transparency in Win IE 5.5 or higher.
 -   {
 -   for(var i=0; i<document.images.length; i++)
 -      {
 -           var img = document.images[i]
 -           var imgName = img.src.toUpperCase()
 -           if (imgName.substring(imgName.length-3, imgName.length) == "PNG" )
 -              {
 -                  var imgID = (img.id) ? "id='" + img.id + "' " : ""
 -                  var imgClass = (img.className) ? "class='" + img.className + "' " : ""
 -                  var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
 -                  var imgStyle = "display:inline-block;" + img.style.cssText
 -                  if (img.align == "left" ) imgStyle = "float:left;" + imgStyle
 -                  if (img.align == "right" ) imgStyle = "float:right;" + imgStyle
 -                  if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle             
 -                  var strNewHTML = "<span " + imgID + imgClass + imgTitle
 -                  + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
 -              + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
 -                  + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
 -                  img.outerHTML = strNewHTML
 -                  i = i-1
 -              }
 -      }
 -   }
 - window.attachEvent("onload", correctPNG);
 - //  ]]>
 - -->
 - </script>
 - <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
 - <title>Miniprofil</title>
 - <style type="text/css">
 - <!--
 - body {
 -         background-color: #5E5E5E;
 - }
 - body,td,th {
 -         font-family: Geneva, Arial, Helvetica, sans-serif;
 -         color: #B0B0B0;
 - }
 - a:link {
 -         color: #B0B0B0;
 -         text-decoration: underline;
 - }
 - a:visited {
 -         text-decoration: underline;
 -         color: #B0B0B0;
 - }
 - a:hover {
 -         text-decoration: none;
 -         color: #B0B0B0;
 - }
 - a:active {
 -         text-decoration: underline;
 -         color: #B0B0B0;
 - }
 - .goldard {
 - font-size:24px;
 -         color: #F8A345;
 - }
 - -->
 - </style>
 - <?php echo $xajax->printJavascript('../xajax_0.2.4/'); ?>
 - <script>
 - function refresh()
 - {
 -         xajax_hp();
 -         setTimeout("refresh()", 5000);
 -                 xajax_goldards();
 -         setTimeout("refresh()", 5000);
 - }
 - </script>
 - </head>
 - <body>
 - <div id="goldards"></div>
 - <div id="hp"></div>
 - </body>
 - </html>
 
  |  
 
   Savez vous où j'ai fais une erreur ?
   Voila l'arborescence des dossiers :
 Racine
 |-xajax_0.2.4
 |-modules
 --|-ce fichier
 |-includes
 --|-config.php
   Merci        |