[AJAX] Saut de fonction AJAX
Voilà le code :
Code:
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
|
//comparaison
function compare_ajax()
{
var xhr=null;
if (window.XMLHttpRequest)
{
xhr = new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
xhr.onreadystatechange=function()
{
if (xhr.readyState==4 && xhr.status == 200)
{
compare(xhr);
}
}
//appel du fichier
xhr.open("GET", "comparaison_droits.php", true);
xhr.send(null);
}
//alert("tableau_checkbox_droits[i].id:"+tableau_checkbox_droits[i].id);
function compare(xhr)//
{
var docXML = xhr.responseXML;
var it_user_id = docXML.getElementsByTagName('user_id');
var droit_id = docXML.getElementsByTagName('droit_id');
/*alert("tableau_checkbox_droits[i].id:"+tableau_cb_droits_id);
alert("user_id:"+user_id);*/
for (j=0; j<it_user_id.length; j++)
{
it_user_id_txt = document.createTextNode(it_user_id.item(j).firstChild.data);
droit_id_txt = document.createTextNode(droit_id.item(j).firstChild.data);
if (droit_id_txt.nodeValue == tableau_cb_droits_id)
{
if (it_user_id_txt.nodeValue == user_id)
{
tableau_checkbox_droits[i].checked = true;
}
}
}
}
//boucle affichage des checkbox
for (i=0; i<item_droit_id.length; i++)
{
tableau_checkbox_droits[i] = document.createElement('input');
tableau_checkbox_droits[i].type = "checkbox";
id_checkbox = document.createTextNode(item_droit_id.item(i).firstChild.data);
tableau_checkbox_droits[i].id = id_checkbox.nodeValue;
tableau_cb_droits = tableau_checkbox_droits[i];
tableau_cb_droits_id = tableau_checkbox_droits[i].id;
//tableau_cb_droits_checked = tableau_checkbox_droits[i].checked;
place.appendChild(tableau_cb_droits);
desc_checkbox = document.createTextNode(item_droit.item(i).firstChild.data);
//tableau_nom_droits[i].name = desc_checkbox.nodeValue;
//alert(tableau_nom_droits[i]);
compare_ajax();//ici j'appelle la fameuse fonction ajax qui déconne
place.appendChild(desc_checkbox);
br2 = document.createElement("br");
place.appendChild(br2);
} |
J'ai un énorme problème avec la fonction compare(xhr) qui est littéralement "oubliée" lors de l'interprétation de mon javascript, je m'en suis rendu compte avec des breakpoints et l'éxecution pas à pas de Chrome et je vois pas pourquoi cette fonction est omise alors qu'elle est appelée par compare_ajax.
ça fait plus de 24 heures que je suis dessus à rien comprendre ... :cry:
Merci d'avance