hey guys,
I have 3 select boxes,
when you choose an option from the first, the second select gets populated based on the first choosen option. Same goes for the third select.
when they submit the data, I want to put back the values in those select based on the URL string. All goes well except for a racing condition.
I tried using a mutex and / or setTimout without success. it always results in an infinite loop.
Using alerts to debug tells me that mutex is true then becomes false when Ajax call has ended.
I know this is some epik javascript needs but I need to know the inner working of this language
thanks
js1.js :
And here comes js2.jsCode:var mutex = false; function doSomethingAjax() { mutex = true; //while im here, mutex is active xmlhttp = GetXmlHttpObject(); if (xmlhttp==null) { alert ("Votre navigateur ne supporte pas le XMLHTTP!"); return; } url = './consulter_ajax.php?id_domaine=' + id_domaine + '&sid=' + Math.random(); xmlhttp.onreadystatechange=doPopulerListeProgrammes; xmlhttp.open("GET",url,true); xmlhttp.send(null); } function doPopulerListeProgrammes(){ if (xmlhttp.readyState==4) { document.getElementById("slcProgrammeIE").innerHTML=xmlhttp.responseText; clearCours(); toggleElementDisable(document.getElementById("niveauADesactiver"), true); //désactive les niveaux mutex = false; //release the mutex } }
Code:function getValeursDepartURL(){ //domaine if(document.getElementById('slcDomaine')){ var domaine = document.getElementById('slcDomaine'); var id_domaine = getValeurURL('slcDomaine'); if(id_domaine){ selectIndexParValeur(domaine, id_domaine); populerListeProgrammes(id_domaine); } } while(mutex){} //INFINITE LOOP //alert(mutex); //= true //alert(mutex); //= false... //Programme if(document.getElementById('slcProgramme')){ var programme = document.getElementById('slcProgramme'); var id_programme = getValeurURL('slcProgramme'); if(id_programme){ selectIndexParValeur(programme, id_programme); populerListeCours(); } }




Reply With Quote

Bookmarks