Ma premiere fonction stop la deuxieme

Par juju.92, il y a 8 ans


Bonjour,
Je ne comprends pas pourquoi lorsque j'appelle mes 2 fonctions reload la premiere fonctionne mais plus la deuxieme alors que si j'en active que une seule elles fonctionnent chacune de leurs cotés...

function nouvelle_question($container) { var ajaxCall = $.ajax({ //context: $(element), //data: someData, //dataType: 'json', type: 'GET', url: 'http://localhost:8890/app/armee_project/index.php/game/ajax_nouvelle_question' }); ajaxCall.done(function(data) { data = $.parseJSON(data); if(data){ // Je dois nettoyer l'ancienne question desactive_animation_reponses(); reload_tags(data); reload_reponses(data['get_reponses']); } }); ajaxCall.fail(function(jqXHR, textStatus, errorThrown) { // If fail console.log(textStatus + ': ' + errorThrown); }); } function reload_tags(data) { var content = $("#ajax_tag"); // Je supprime les anciens content.empty(); // Je creer les nouveaux tags var array = data['get_tags']; var json = array.length; for (var i = 0, l = json; i <= l; i++) { var result = $('<div class="tag"> \ <span style="color : '+data['get_matiere'].couleur+'" class="icon-tag"></span> \ '+array[i].name+' \ </div>'); content.append(result); } } function reload_reponses(data) { var content = $("#bloc_reponse"); // Je supprime les anciens content.empty(); // Je creer les nouvelles reponses var array = data; var json = array.length; for (var i = 0, l = json; i <= l; i++) { //console.log(array[i].etat); var result = $('<div class="reponse reponse_hover> \ <input type="radio" name="reponse" value="'+array[i].etat+'"> \ <label class="label_hover" for="reponse">'+array[i].reponse+' \ <div class="puce"></div> \ <div class="puce_animation"></div> \ <svg class="svg_cross" version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 130.2 130.2"> \ <line class="path line" fill="none" stroke="#eaa99d" stroke-width="8" stroke-linecap="round" stroke-miterlimit="10" x1="34.4" y1="37.9" x2="95.8" y2="92.3"/> \ <line class="path line" fill="none" stroke="#eaa99d" stroke-width="8" stroke-linecap="round" stroke-miterlimit="10" x1="95.8" y1="38" x2="34.4" y2="92.2"/> \ </svg> \ <svg class="svg_check" version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 130.2 130.2"> \ <polyline class="path check" fill="none" stroke="#c2efeb" stroke-width="8" stroke-linecap="round" stroke-miterlimit="10" points="100.2,40.2 51.5,88.8 29.8,67.5 "/> \ </svg> \ </label> \ </div>'); content.append(result); $(result).css('height',hauteur_bloc_reponse); puce_game(); } }

Merci d'avance pour ceux qui peuvent m'expliquer !

1 réponse

juju.92, il y a 8 ans

J'ai reussi a m'en sortir avec des each.

function reload_tags(data) { var content = $("#ajax_tag"); // Je supprime les anciens content.empty(); // Je creer les nouveaux tags var array = data['get_tags']; var json = array.length; var i = 0; $.each(array, function(i, json) { var result = $('<div class="tag"> \ <span style="color : '+data['get_matiere'].couleur+'" class="icon-tag"></span> \ '+array[i].name+' \ </div>'); content.append(result); }); }