IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

AJAX Discussion :

[AJAX] Bug double liste


Sujet :

AJAX

  1. #1
    Membre averti
    Profil pro
    Inscrit en
    Juillet 2009
    Messages
    24
    Détails du profil
    Informations personnelles :
    Âge : 44
    Localisation : France

    Informations forums :
    Inscription : Juillet 2009
    Messages : 24
    Par défaut [AJAX] Bug double liste
    Bonjour,

    Je dois reprendre un script qui bug et je ne vois pas trop le souci. Le menu en double liste fonctionne bien sous Firefox et IE8 mais bug sur les autes versions.

    Je vous laisse prendre connaissance du bug et vous invite à me MP pour vous envoyer le code.

    http://www.euxos.com/site/recherche/...p?fab=%&proj=0

    Merci d'avance,

  2. #2
    Expert éminent

    Homme Profil pro
    Inscrit en
    Janvier 2007
    Messages
    13 474
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Secteur : Finance

    Informations forums :
    Inscription : Janvier 2007
    Messages : 13 474
    Par défaut
    Bonjour,
    Citation Envoyé par Mathieu92130 Voir le message
    Je vous laisse prendre connaissance du bug et vous invite à me MP pour vous envoyer le code.
    on va pas faire comme ça

    Merci de décrire précisément le problème, de copier/coller ici les parties de code incriminées (HTML généré et Javascript) et de décrire le comportement du navigateur ainsi que les erreurs signalées (message et ligne du code concernée)

    A+

  3. #3
    Membre averti
    Profil pro
    Inscrit en
    Juillet 2009
    Messages
    24
    Détails du profil
    Informations personnelles :
    Âge : 44
    Localisation : France

    Informations forums :
    Inscription : Juillet 2009
    Messages : 24
    Par défaut
    Voilà, j'ai cette fois ci plus de temps pour écrire mon message

    Donc j'ai récupéré un site avec un code que je ne comprends pas trop sur certains points, en l'occurence sur le menu en double liste que l'on trouve ici:
    http://www.euxos.com/site/recherche/...p?fab=%&proj=0

    Le bug sur IE < 8 ou Safari est que peu importe le choix effectué dans la première liste, la deuxième ne se met pas à jour.

    Voici le js appelé

    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
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    // JavaScript Document
    //window.onload = testerNavigateur;
    //-----------------------------
    function testerNavigateur(type_fab, type_proj) {   
    	objetXHR = creationXHR();
    	if(objetXHR==null) {
    		document.getElementById("button").disabled= true;
    		var erreurNavigateur="Erreur Navigateur : Création d'objet XHR impossible";
    		remplacerContenu("info", erreurNavigateur);
    	    document.getElementById("info").style.visibility="visible";
    	}
    	//alert("Fab: "+type_fab+" - Proj: " + type_proj);
    	document.getElementById("button").onclick=jouer;
    	document.getElementById("categorie").onchange=function() {recupScategorie(this.value);}
    	document.getElementById("scategorie").onchange=function() {demandePieces(type_fab, type_proj);}
    }
    //##############################MOTEUR AJAX 1############################################
    function jouer() {   
    	 /*-----------------------------Config et envoi de la requete ASYNCHRONE : */
    	 objetXHR = creationXHR();//création d'un objet XHR multi-navigateurs
    	 var temps = new Date().getTime();//création d'une variable temps pour l'anti-cache
    	 //construction de la chaine des parametres
    	 var parametres = "categorie="+ codeContenu("categorie") +
    	 				  "&scategorie="+ codeContenu("scategorie") +
    	                  "&anticache="+temps ;
    	 //Config. objet XHR
         objetXHR.open("get","gainAleatoire.php?"+parametres, true); 
    	 objetXHR.onreadystatechange = actualiserPage;//désignation de la fonction de rappel
    	 //gestion du bouton et du chargeur
    	 document.getElementById("button").disabled= true;
    	 document.getElementById("charge").style.visibility="visible";
         objetXHR.send(null);//envoi de la requete
    	 /*---------------------------------------- */
      }
      function actualiserPage() {
    	if (objetXHR.readyState == 4) {//test si le résultat est disponible
    	 if (objetXHR.status == 200) {
    	   demandeGains();
           var nouveauResultat = objetXHR.responseText.split(":");//recup du résulat > tableau 
    	   //actualisation du résultat
    	   remplacerContenu("resultat", decodeURI(nouveauResultat[1]));
    	   //actualisation du nom
    	   remplacerContenu("gagnant", decodeURI(nouveauResultat[0]));
    	   //affiche la zone info
    	   document.getElementById("info").style.visibility="visible";
    	   //gestion du bouton et du chargeur
    	   document.getElementById("button").disabled= false;
    	   document.getElementById("charge").style.visibility="hidden";
    	 }else{
    	   //message d'erreur serveur
    	   var erreurServeur="Erreur serveur : "+objetXHR.status+" – "+ objetXHR.statusText;
    	   remplacerContenu("info", erreurServeur);
    	   document.getElementById("info").style.visibility="visible";
    	   //gestion du bouton et du chargeur
    	   document.getElementById("button").disabled= false;
    	   document.getElementById("charge").style.visibility="hidden";
    	   //annule la requete en cours
    	   objetXHR.abort();
    	   objetXHR=null;
    	   }
    	 }
      }
     
    //##############################MOTEUR AJAX 3############################################
    function demandePieces(type_fab, type_proj) {   
     //création d'un objet XHR multi-navigateurs
     objetXHR3 = creationXHR();
     var temps = new Date().getTime();//création d'une variable temps pour l'anti-cache
     //construction de la chaine des parametres
     var parametres3 = "scategorie="+ codeContenu("scategorie") +
                       "&fab="+ type_fab +
    				   "&proj="+ type_proj +
    	               "&anticache="+temps ;
     //Config. objet XHR
    // alert("URL: " + "piecesListe.php?"+parametres3)
     objetXHR3.open("get","piecesListe.php?"+parametres3, true); 
     objetXHR3.onreadystatechange = affichepieces;//désignation de la fonction de rappel
     objetXHR3.send(null);//envoi de la requete
     }
     
    function affichepieces() {
    	if (objetXHR3.readyState == 4) {//test si le résultat est disponible
    	 if (objetXHR3.status == 200) {
    	   listeJSON = objetXHR3.responseText;//recup du résulat > objet JSON
    	   objetJSON3=listeJSON.parseJSON();
    	   //créa des nouvelles lignes
    	   var tableListe=document.getElementById("tableListe");
    	   supprimerContenu(tableListe);
    	   for(i=0;i<objetJSON3.pieces.length;i++){
    	   	 var image=objetJSON3.pieces[i].image;
    		 var reference=objetJSON3.pieces[i].reference;
    		 var designation1=objetJSON3.pieces[i].designation1;
    		 var raisonsoc=objetJSON3.pieces[i].raisonsoc;
    		 var id=objetJSON3.pieces[i].id;
    		 var nbResults=objetJSON3.pieces[i].nbPieces + ' produit(s) correspond(ent) a votre recherche';
    		 if(i==0){
    		    var tmpTR=document.createElement('tr');
    		    var tmpTD=document.createElement('td');
    	   	 	var tmpTXT=document.createTextNode(nbResults);
    		    tmpTD.setAttribute('colspan','4');
    			tmpTD.setAttribute('class','chevron');
    	   	    tmpTD.appendChild(tmpTXT);
    	   	    tmpTR.appendChild(tmpTD);
    			tableListe.appendChild(tmpTR);
    		 }
    	     nouvelleLigne(tableListe,designation1,raisonsoc,reference,id,image);
    	   }
    	 }else{
    	   //message d'erreur serveur
    	   var erreurServeur="Erreur serveur : "+objetXHR3.status+" – "+ objetXHR3.statusText;
    	   remplacerContenu("info", erreurServeur);
    	   document.getElementById("info").style.visibility="visible";
    	   //gestion du bouton et du chargeur
    	   document.getElementById("button").disabled= false;
    	   //annule la requete en cours
    	   objetXHR3.abort();
    	   objetXHR3=null;
    	   }
    	 }
      }
      //-----------------------------------------
    function nouvelleLigne(tab,text1,text2, text3,text4) { 
    	   var nouveauTR=document.createElement('ul');
    	   nouveauTR.setAttribute('class','rechliste')
    	   //-----------------------------------------
    	   var nouveauTD1=document.createElement('li');
    	   nouveauTD1.setAttribute('class','descri');
    	   var nouveauTXT1=document.createTextNode(text1);
    	   nouveauTD1.appendChild(nouveauTXT1);
     
    	   var nouveauTD2=document.createElement('li');
    	   nouveauTD2.setAttribute('class','construc');
    	   var nouveauTXT2=document.createTextNode(text2);
    	   nouveauTD2.appendChild(nouveauTXT2);
     
    	   var nouveauTD3=document.createElement('li');
    	   nouveauTD3.setAttribute('class','liens');
    	   var nouveauTXT3=document.createTextNode(text3);
    	   nouveauTD3.appendChild(nouveauTXT3);
     
    	   var nouveauTD4=document.createElement('li');
    	   nouveauTD4.setAttribute('class','test')
     
    	   nouveauTD3.setAttribute('class','ref');
     
    	   //var nouveauA6=document.createElement('img');
    	   //nouveauA6.setAttribute('src', '../images/'+text4'.gif');
     
     
           // Bouton Détails
           var nouveauA4=document.createElement('a');
           nouveauA4.setAttribute('href','../detailproduit.php?id='+text4);
           var nouveauA5=document.createElement('img');
    	   nouveauA5.setAttribute('src','../img/detail.png');
           nouveauA4.appendChild(nouveauA5);
           nouveauTD4.appendChild(nouveauA4); 
     
     
    	   //------------------------------------------
    	   nouveauTR.appendChild(nouveauTD1);
    	   nouveauTR.appendChild(nouveauTD2);
    	   nouveauTR.appendChild(nouveauTD3);
    	   nouveauTR.appendChild(nouveauTD4);
    	   //------------------------------------------
    	   tab.appendChild(nouveauTR);
    }
    //##############################MOTEUR AJAX 4############################################
     
    function recupScategorie(categorie) {  
    	 //reinitialise les options du menu 2 a chaque changement
    	  document.getElementById("scategorie").options.length = 1;
    	 //cas ou il n'y a pas de nom sélectionné	
    	 if (categorie == "") return null ;
    	 //--------------------
    	 objetXHR4 = creationXHR();//création d'un objet XHR multi-navigateurs
    	 var temps = new Date().getTime();//création d'une variable temps pour l'anti-cache
    	 //construction de la chaine des parametres
    	 var parametres = "categorie="+ categorie +
    	                  "&anticache="+temps ;
    	 //alert('scategorieListe.php?' + parametres);
    	 //Config. objet XHR
         objetXHR4.open("get","scategorieListe.php?"+parametres, true); 
    	 objetXHR4.onreadystatechange = creationMenu2;//désignation de la fonction de rappel
    	 //gestion du bouton et du chargeur
         objetXHR4.send(null);//envoi de la requete
    	 /*---------------------------------------- */
      }
     
    function creationMenu2(){
    	if (objetXHR4.readyState == 4) {//test si le résultat est disponible
    	 if (objetXHR4.status == 200) {
    	   //recup du résulat au format TXT 
    	   var nouveauResultat = objetXHR4.responseText;
    	   //conversion de chaine JSON en objet JSON
    	   var objetJSON=nouveauResultat.parseJSON();
    	   //création du menu dans le DOM>>dans fonction de rappel
    		for (i=0; i<objetJSON.listeScategorie.length; i++)
    			{
    //			  var elementOption = document.createElement('option'); 
    //			  var texteOption = document.createTextNode(objetJSON.listeScategorie[i].scategorie); 
    //			  elementOption.setAttribute('value',objetJSON.listeScategorie[i].etiquettesr);  
    //			  elementOption.setAttribute('value',objetJSON.listeScategorie[i].etiquettesr);  
    //			  elementOption.appendChild(texteOption); 
    //			  document.getElementById("scategorie").appendChild(elementOption); 
    		      var elmt = new Option(objetJSON.listeScategorie[i].descriptifsr, objetJSON.listeScategorie[i].etiquettesr);
    			  var ddl = document.getElementById("scategorie");
    			  ddl.add(elmt, null);
    			}
    	}
    	}
    }
    J'ai mis la totalité tel que je l'ai récupéré. Navré pour la longueur.

    Voici la page php:

    Code php : 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
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    <!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">
    <?php
    $var='catalogue';
    $type_fab=0;
    if(isset($_GET['fab']))
    	$type_fab = $_GET['fab'];
    else
    	$type_fab=="%";
    if(isset($_GET['proj']))
    	$type_proj = $_GET['proj'];
    else
       $type_proj=="%";
    ?>
    <head>
    <!--<META HTTP-EQUIV='Pragma' CONTENT='no-cache'>-->
      <meta content="text/html; Charset=iso-8859-1" http-equiv="Content-Type" />
      <title>recherche de pieces Euxos</title>
      <link rel="stylesheet" type="text/css" href="style.css" />
     
      <script type="text/javascript" src="fonctionsAjax.js"></script>
      <script type="text/javascript" src="fonctionsMachine.js"></script>
      <script type="text/javascript" src="json.js"></script>
      <link href="../pages/euxos_public.css" rel="stylesheet" type="text/css" />
    </head>
     
    <body onload="javascript:testerNavigateur('<?php echo $type_fab; ?>','<?php echo $type_proj; ?>');MM_preloadImages('../img/detail.png')" >
     
    <div id="containeur" >
    	<div id="head"><?php include('../nav2.php'); ?></div>
     
    	<div id="main">
    	<!--zone du chargeur-->
    	<img id="charge" src="chargeur.gif"  />
    		<div id="fab">
    			<?php if ($type_fab!='%') { ?>
    			<img src="../admin/img/<?php echo $type_fab; ?>_o.jpg" align="middle" title="fabriquant" />&nbsp;
    			<?php ;} elseif  ($type_proj!='0') { ?>
    			<img src="../admin/projet/<?php echo $type_proj; ?>_o.jpg" align="middle" title="projet" />&nbsp;
    			<?php ;} else {?>
    			<img src="../admin/projet/null_o.jpg" align="middle" title="euxos" />&nbsp;
    			<?php ;} ?>
    		</div>
     
    		<!--zone du formulaire-->
    		<div id="formulaire">
    			<div id="superieur"></div>
    			<form>
    				<span class="chevron" >></span>
    				<?php
    				require_once('../Connections/dbconnect.php');
    				mysql_select_db($database_dbconnect);
    				$requeteSQL="SELECT DISTINCT rubrique.etiquetter, rubrique.id, rubrique.descriptifr
    				FROM piece, rubrique WHERE rubrique.etiquetter=piece.rubrique_id AND rubrique.etiquetter=piece.rubrique_id AND piece.fabricant_id LIKE '".$type_fab."' ORDER BY rubrique.descriptifr";
    				$reponseSQL = mysql_query($requeteSQL);
    				//echo $requeteSQL;
    				echo "<select name='categorie' id='categorie'>";
    				echo "<option value=''>S&eacute;lectionner votre cat&eacute;gorie</option>";
    				while ($donnees = mysql_fetch_array($reponseSQL)) {
    				echo "
    				<option value='".$donnees['id']."'> ".$donnees['descriptifr']." </option>";
    				}
    				echo "</select>";  
    				?>
    				<br/>
    				<select name='scategorie' id='scategorie'>
    				<option selected="selected" >S&eacute;lectionner la sous-cat&eacute;gorie</option>
    				</select>
     
    				<input name="button" id="button" type="hidden"  value="voir" />
    			</form>
     
    			<div id="inferieur"></div>
     
    			<!--liste des gains-->
    			<div id="commentaire">
    				<table width="730" border="0" align="center" cellpadding="5" cellspacing="0" >
    					<div id="tableListe">
    						<ul>
    							<li>&nbsp;</li>
    						</ul>
    					</div>
    				</table>
    			</div><!-- Fin de commentaire -->
    			<!-- Fin des gains -->
    		</div><!-- Fin formulaire -->
    		<div class="clear"></div>
     
    	</div><!-- Fin de main -->
     
     
    </div><!-- Fin Conteneur -->
     
    <div id="footer"><?php include('../pied.php'); ?></div>
     
    </body>
    </html>

    Toute aide sera fortement appréciée,

    Merci d'avance,

  4. #4
    Expert éminent

    Homme Profil pro
    Inscrit en
    Janvier 2007
    Messages
    13 474
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Secteur : Finance

    Informations forums :
    Inscription : Janvier 2007
    Messages : 13 474
    Par défaut
    On voit mieux où on va
    Citation Envoyé par Mathieu92130 Voir le message
    Le bug sur IE < 8 ou Safari est que peu importe le choix effectué dans la première liste, la deuxième ne se met pas à jour.
    Tu dois avoir un message d'erreur, dans ce cas. Lequel ?
    (vérifie que tu as bien activé la "notification des erreurs de scripts" -ou équivalent- de ton nav)

    A+

  5. #5
    Membre averti
    Profil pro
    Inscrit en
    Juillet 2009
    Messages
    24
    Détails du profil
    Informations personnelles :
    Âge : 44
    Localisation : France

    Informations forums :
    Inscription : Juillet 2009
    Messages : 24
    Par défaut
    Voici le message d'erreur:

    Ligne: 208
    Caractère: 6
    Erreur: le type ne correspond pas
    Code: 0

  6. #6
    Expert éminent

    Homme Profil pro
    Inscrit en
    Janvier 2007
    Messages
    13 474
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Secteur : Finance

    Informations forums :
    Inscription : Janvier 2007
    Messages : 13 474
    Par défaut
    Citation Envoyé par Mathieu92130 Voir le message
    Ligne: 208
    Ce qui semble correspondre à la ligne vérifie le type de ce que tu récupères dans "elmt" (et celui attendu par la méthode add() )
    vérifie que "null" est autorisé en 2° paramètre (tu as essayé avec "" ?)

    A+

  7. #7
    Membre averti
    Profil pro
    Inscrit en
    Juillet 2009
    Messages
    24
    Détails du profil
    Informations personnelles :
    Âge : 44
    Localisation : France

    Informations forums :
    Inscription : Juillet 2009
    Messages : 24
    Par défaut
    Citation Envoyé par E.Bzz Voir le message
    Ce qui semble correspondre à la ligne vérifie le type de ce que tu récupères dans "elmt" (et celui attendu par la méthode add() )
    vérifie que "null" est autorisé en 2° paramètre (tu as essayé avec "" ?)
    A+
    Merci pour ta réponse.

    Je viens d'essayer avec "" mais malheureusement, pas d'effet positif. Je continue mes recherches

  8. #8
    Expert éminent

    Homme Profil pro
    Inscrit en
    Janvier 2007
    Messages
    13 474
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Secteur : Finance

    Informations forums :
    Inscription : Janvier 2007
    Messages : 13 474
    Par défaut
    Citation Envoyé par Mathieu92130 Voir le message
    Je viens d'essayer avec "" mais malheureusement, pas d'effet positif. Je continue mes recherches
    Bon, ben visiblement le "null" est tout à fait correct ....

    Tu as essayé avec createElement() comme dans le lien, au lieu de new Option() ?

    EDIT :
    La doc IE correspond à ce que tu as fait, pourtant (y/c le new Option() )

    A+

  9. #9
    Membre averti
    Profil pro
    Inscrit en
    Juillet 2009
    Messages
    24
    Détails du profil
    Informations personnelles :
    Âge : 44
    Localisation : France

    Informations forums :
    Inscription : Juillet 2009
    Messages : 24
    Par défaut
    le createElement() ne passe pas, et la première liste déroulante ne se charge même plus sur Firefox.

    Merci pour tes liens, je les potasse en m'arrachant les cheveux sur le script

  10. #10
    Membre averti
    Profil pro
    Inscrit en
    Juillet 2009
    Messages
    24
    Détails du profil
    Informations personnelles :
    Âge : 44
    Localisation : France

    Informations forums :
    Inscription : Juillet 2009
    Messages : 24
    Par défaut
    Impossible de trouver l'erreur malgré les sources citées dans tes réponses.

    Je continue mes recherches mais si une autre idée te vient à l'esprit, je reste ouvert

  11. #11
    Rédacteur

    Avatar de Bovino
    Homme Profil pro
    Développeur Web
    Inscrit en
    Juin 2008
    Messages
    23 647
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 54
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2008
    Messages : 23 647
    Billets dans le blog
    20
    Par défaut
    Attention, le second paramètre de add doit correspondre au rang que doit avoir l'option insérée (éventuellement pour IE8 et Opera, une référence à l'objet option avant lequel insérer la nouvelle, null n'est donc pas une valeur correcte

    Essaye simplement
    Pas de question technique par MP !
    Tout le monde peut participer à developpez.com, vous avez une idée, contactez-moi !
    Mes formations video2brain : La formation complète sur JavaScriptJavaScript et le DOM par la pratiquePHP 5 et MySQL : les fondamentaux
    Mon livre sur jQuery
    Module Firefox / Chrome d'intégration de JSFiddle et CodePen sur le forum

  12. #12
    Membre averti
    Profil pro
    Inscrit en
    Juillet 2009
    Messages
    24
    Détails du profil
    Informations personnelles :
    Âge : 44
    Localisation : France

    Informations forums :
    Inscription : Juillet 2009
    Messages : 24
    Par défaut
    Je viens d'essayer mais cela ne fonctionne pas, et provoque même l'erreur sur Firefox.

    Merci quand même pour ton message

  13. #13
    Expert éminent

    Homme Profil pro
    Inscrit en
    Janvier 2007
    Messages
    13 474
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Secteur : Finance

    Informations forums :
    Inscription : Janvier 2007
    Messages : 13 474
    Par défaut
    Citation Envoyé par Bovino Voir le message
    null n'est donc pas une valeur correcte
    Ben il est reconnu à la fois côté MSDN et côté Mozilla
    Citation Envoyé par Mozilla
    If this parameter is null, the new element is appended to the end of the collection.
    Citation Envoyé par MSDN
    Object that specifies an element to insert before, or null to append the object to the collection.
    A+

  14. #14
    Membre averti
    Profil pro
    Inscrit en
    Juillet 2009
    Messages
    24
    Détails du profil
    Informations personnelles :
    Âge : 44
    Localisation : France

    Informations forums :
    Inscription : Juillet 2009
    Messages : 24
    Par défaut
    Oui, je suis un peu perdu et plus d cheveux sur la tête à force de les arracher

  15. #15
    Expert éminent

    Homme Profil pro
    Inscrit en
    Janvier 2007
    Messages
    13 474
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Secteur : Finance

    Informations forums :
    Inscription : Janvier 2007
    Messages : 13 474
    Par défaut
    Tu n'aurais pas simplement une des options récupérées dont le contenu pourrait planter le traitement ?

    A+

  16. #16
    Rédacteur

    Avatar de Bovino
    Homme Profil pro
    Développeur Web
    Inscrit en
    Juin 2008
    Messages
    23 647
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 54
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2008
    Messages : 23 647
    Billets dans le blog
    20
    Par défaut
    Citation Envoyé par MSDN
    Windows Internet Explorer 8 and later. Object that specifies an element to insert before, or null to append the object to the collection.
    Pas de question technique par MP !
    Tout le monde peut participer à developpez.com, vous avez une idée, contactez-moi !
    Mes formations video2brain : La formation complète sur JavaScriptJavaScript et le DOM par la pratiquePHP 5 et MySQL : les fondamentaux
    Mon livre sur jQuery
    Module Firefox / Chrome d'intégration de JSFiddle et CodePen sur le forum

  17. #17
    Expert éminent

    Homme Profil pro
    Inscrit en
    Janvier 2007
    Messages
    13 474
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Secteur : Finance

    Informations forums :
    Inscription : Janvier 2007
    Messages : 13 474
    Par défaut
    Arf !

    Au temps pour moi ...

    A+

  18. #18
    Rédacteur

    Avatar de Bovino
    Homme Profil pro
    Développeur Web
    Inscrit en
    Juin 2008
    Messages
    23 647
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 54
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2008
    Messages : 23 647
    Billets dans le blog
    20
    Par défaut
    Bah, ça arrive

    @Mathieu92130 : ton JSON, il ressemble à quoi ?
    Pas de question technique par MP !
    Tout le monde peut participer à developpez.com, vous avez une idée, contactez-moi !
    Mes formations video2brain : La formation complète sur JavaScriptJavaScript et le DOM par la pratiquePHP 5 et MySQL : les fondamentaux
    Mon livre sur jQuery
    Module Firefox / Chrome d'intégration de JSFiddle et CodePen sur le forum

  19. #19
    Membre averti
    Profil pro
    Inscrit en
    Juillet 2009
    Messages
    24
    Détails du profil
    Informations personnelles :
    Âge : 44
    Localisation : France

    Informations forums :
    Inscription : Juillet 2009
    Messages : 24
    Par défaut
    Voici le Json

    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
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    /*
        json.js
        2007-08-19
     
        Public Domain
     
        This file adds these methods to JavaScript:
     
            array.toJSONString(whitelist)
            boolean.toJSONString()
            date.toJSONString()
            number.toJSONString()
            object.toJSONString(whitelist)
            string.toJSONString()
                These methods produce a JSON text from a JavaScript value.
                It must not contain any cyclical references. Illegal values
                will be excluded.
     
                The default conversion for dates is to an ISO string. You can
                add a toJSONString method to any date object to get a different
                representation.
     
                The object and array methods can take an optional whitelist
                argument. A whitelist is an array of strings. If it is provided,
                keys in objects not found in the whitelist are excluded.
     
            string.parseJSON(filter)
                This method parses a JSON text to produce an object or
                array. It can throw a SyntaxError exception.
     
                The optional filter parameter is a function which can filter and
                transform the results. It receives each of the keys and values, and
                its return value is used instead of the original value. If it
                returns what it received, then structure is not modified. If it
                returns undefined then the member is deleted.
     
                Example:
     
                // Parse the text. If a key contains the string 'date' then
                // convert the value to a date.
     
                myData = text.parseJSON(function (key, value) {
                    return key.indexOf('date') >= 0 ? new Date(value) : value;
                });
     
        It is expected that these methods will formally become part of the
        JavaScript Programming Language in the Fourth Edition of the
        ECMAScript standard in 2008.
     
        This file will break programs with improper for..in loops. See
        http://yuiblog.com/blog/2006/09/26/for-in-intrigue/
     
        This is a reference implementation. You are free to copy, modify, or
        redistribute.
     
        Use your own copy. It is extremely unwise to load untrusted third party
        code into your pages.
    */
     
    /*jslint evil: true */
     
    // Augment the basic prototypes if they have not already been augmented.
     
    if (!Object.prototype.toJSONString) {
     
        Array.prototype.toJSONString = function (w) {
            var a = [],     // The array holding the partial texts.
                i,          // Loop counter.
                l = this.length,
                v;          // The value to be stringified.
     
    // For each value in this array...
     
            for (i = 0; i < l; i += 1) {
                v = this[i];
                switch (typeof v) {
                case 'object':
     
    // Serialize a JavaScript object value. Ignore objects thats lack the
    // toJSONString method. Due to a specification error in ECMAScript,
    // typeof null is 'object', so watch out for that case.
     
                    if (v) {
                        if (typeof v.toJSONString === 'function') {
                            a.push(v.toJSONString(w));
                        }
                    } else {
                        a.push('null');
                    }
                    break;
     
                case 'string':
                case 'number':
                case 'boolean':
                    a.push(v.toJSONString());
     
    // Values without a JSON representation are ignored.
     
                }
            }
     
    // Join all of the member texts together and wrap them in brackets.
     
            return '[' + a.join(',') + ']';
        };
     
     
        Boolean.prototype.toJSONString = function () {
            return String(this);
        };
     
     
        Date.prototype.toJSONString = function () {
     
    // Eventually, this method will be based on the date.toISOString method.
     
            function f(n) {
     
    // Format integers to have at least two digits.
     
                return n < 10 ? '0' + n : n;
            }
     
            return '"' + this.getUTCFullYear() + '-' +
                    f(this.getUTCMonth() + 1)  + '-' +
                    f(this.getUTCDate())       + 'T' +
                    f(this.getUTCHours())      + ':' +
                    f(this.getUTCMinutes())    + ':' +
                    f(this.getUTCSeconds())    + 'Z"';
        };
     
     
        Number.prototype.toJSONString = function () {
     
    // JSON numbers must be finite. Encode non-finite numbers as null.
     
            return isFinite(this) ? String(this) : 'null';
        };
     
     
        Object.prototype.toJSONString = function (w) {
            var a = [],     // The array holding the partial texts.
                k,          // The current key.
                i,          // The loop counter.
                v;          // The current value.
     
    // If a whitelist (array of keys) is provided, use it assemble the components
    // of the object.
     
            if (w) {
                for (i = 0; i < w.length; i += 1) {
                    k = w[i];
                    if (typeof k === 'string') {
                        v = this[k];
                        switch (typeof v) {
                        case 'object':
     
    // Serialize a JavaScript object value. Ignore objects that lack the
    // toJSONString method. Due to a specification error in ECMAScript,
    // typeof null is 'object', so watch out for that case.
     
                            if (v) {
                                if (typeof v.toJSONString === 'function') {
                                    a.push(k.toJSONString() + ':' +
                                           v.toJSONString(w));
                                }
                            } else {
                                a.push(k.toJSONString() + ':null');
                            }
                            break;
     
                        case 'string':
                        case 'number':
                        case 'boolean':
                            a.push(k.toJSONString() + ':' + v.toJSONString());
     
    // Values without a JSON representation are ignored.
     
                        }
                    }
                }
            } else {
     
    // Iterate through all of the keys in the object, ignoring the proto chain
    // and keys that are not strings.
     
                for (k in this) {
                    if (typeof k === 'string' &&
                            Object.prototype.hasOwnProperty.apply(this, [k])) {
                        v = this[k];
                        switch (typeof v) {
                        case 'object':
     
    // Serialize a JavaScript object value. Ignore objects that lack the
    // toJSONString method. Due to a specification error in ECMAScript,
    // typeof null is 'object', so watch out for that case.
     
                            if (v) {
                                if (typeof v.toJSONString === 'function') {
                                    a.push(k.toJSONString() + ':' +
                                           v.toJSONString());
                                }
                            } else {
                                a.push(k.toJSONString() + ':null');
                            }
                            break;
     
                        case 'string':
                        case 'number':
                        case 'boolean':
                            a.push(k.toJSONString() + ':' + v.toJSONString());
     
    // Values without a JSON representation are ignored.
     
                        }
                    }
                }
            }
     
    // Join all of the member texts together and wrap them in braces.
     
            return '{' + a.join(',') + '}';
        };
     
     
        (function (s) {
     
    // Augment String.prototype. We do this in an immediate anonymous function to
    // avoid defining global variables.
     
    // m is a table of character substitutions.
     
            var m = {
                '\b': '\\b',
                '\t': '\\t',
                '\n': '\\n',
                '\f': '\\f',
                '\r': '\\r',
                '"' : '\\"',
                '\\': '\\\\'
            };
     
     
            s.parseJSON = function (filter) {
                var j;
     
                function walk(k, v) {
                    var i;
                    if (v && typeof v === 'object') {
                        for (i in v) {
                            if (Object.prototype.hasOwnProperty.apply(v, [i])) {
                                v[i] = walk(i, v[i]);
                            }
                        }
                    }
                    return filter(k, v);
                }
     
     
    // Parsing happens in three stages. In the first stage, we run the text against
    // a regular expression which looks for non-JSON characters. We are especially
    // concerned with '()' and 'new' because they can cause invocation, and '='
    // because it can cause mutation. But just to be safe, we will reject all
    // unexpected characters.
     
    // We split the first stage into 3 regexp operations in order to work around
    // crippling deficiencies in Safari's regexp engine. First we replace all
    // backslash pairs with '@' (a non-JSON character). Second we delete all of
    // the string literals. Third, we look to see if only JSON characters
    // remain. If so, then the text is safe for eval.
     
                if (/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/.test(this.
                        replace(/\\./g, '@').
                        replace(/"[^"\\\n\r]*"/g, ''))) {
     
    // In the second stage we use the eval function to compile the text into a
    // JavaScript structure. The '{' operator is subject to a syntactic ambiguity
    // in JavaScript: it can begin a block or an object literal. We wrap the text
    // in parens to eliminate the ambiguity.
     
                    j = eval('(' + this + ')');
     
    // In the optional third stage, we recursively walk the new structure, passing
    // each name/value pair to a filter function for possible transformation.
     
                    return typeof filter === 'function' ? walk('', j) : j;
                }
     
    // If the text is not JSON parseable, then a SyntaxError is thrown.
     
                throw new SyntaxError('parseJSON');
            };
     
     
            s.toJSONString = function () {
     
    // If the string contains no control characters, no quote characters, and no
    // backslash characters, then we can simply slap some quotes around it.
    // Otherwise we must also replace the offending characters with safe
    // sequences.
     
                if (/["\\\x00-\x1f]/.test(this)) {
                    return '"' + this.replace(/[\x00-\x1f\\"]/g, function (a) {
                        var c = m[a];
                        if (c) {
                            return c;
                        }
                        c = a.charCodeAt();
                        return '\\u00' +
                            Math.floor(c / 16).toString(16) +
                            (c % 16).toString(16);
                    }) + '"';
                }
                return '"' + this + '"';
            };
        })(String.prototype);
    }

  20. #20
    Expert éminent

    Homme Profil pro
    Inscrit en
    Janvier 2007
    Messages
    13 474
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Secteur : Finance

    Informations forums :
    Inscription : Janvier 2007
    Messages : 13 474
    Par défaut
    Citation Envoyé par Mathieu92130 Voir le message
    Voici le Json
    Je suppose que Bovino parlait de la réponse reçue par Ajax.
    Le contenu au format JSon qui sert à alimenter ta liste quoi

    A+

Discussions similaires

  1. [Ajax] Bug introuvable
    Par Davboc dans le forum Général JavaScript
    Réponses: 8
    Dernier message: 09/02/2006, 11h09
  2. pb code double liste
    Par clairette dans le forum Général JavaScript
    Réponses: 6
    Dernier message: 01/02/2006, 11h21
  3. double liste php
    Par clairette dans le forum Langage
    Réponses: 3
    Dernier message: 31/01/2006, 17h06
  4. Probleme avec les double Liste chainees
    Par BernardT dans le forum Langage
    Réponses: 1
    Dernier message: 12/07/2005, 17h22

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo