Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #22755
| Newsgroups | comp.lang.javascript |
|---|---|
| Subject | Re: Wait between different Calls (procedures) |
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
| References | <d583e3d7-af49-42a3-a979-a48d294537d0@googlegroups.com> |
| Date | 2014-01-23 11:06 +0100 |
| Message-ID | <XnsA2BE70EB6EADCeejj99@194.109.133.133> (permalink) |
frank.catry@gmail.com wrote on 23 jan 2014 in comp.lang.javascript:
> Hi,
>
> i have to populate 3 <select></selects> dom's regarding the content of
> the database. Wehn the user wish to update a record. In my case Class,
> Make and model of a car. However when i try to execute the 3 getContent
> calls on the bottom of the code it doesn't work. One by one is oké. How
> can i put a WAIT till finished between the getContent calls ? Frank.
>
> <?
> //data from the database;
> $oriClasse="Car";
> $oriMake="BMW";
> $oriModel="118";
> ?>
Please do not use strange languages in this NG,
I for one do not want to understand them.
>
> <script type="text/javascript">
>
> var domObj="";
>
> function getContent(theDom,theUrl){
>
> ajaxObj = GetXmlHttpObject();
The variable ajaxObj gets overwritten by the second call,
before ajaxObj.onreadystatechange=updateDom; materializes.
> domObj=theDom;
Also this variable gets overwritten.
The solution is to make the 3 calls each have their own functions with
variables, you need them as globals in function updateDom,
or to call them with suitable timeOuts.
The first solution was tried by me and has theoretical advantages.
> ajaxObj.open("GET", theUrl , true);
> ajaxObj.onreadystatechange=updateDom;
> ajaxObj.send(null);
>}
>
> function updateDom(){
> if (ajaxObj.readyState == 4 || ajaxObj.readyState == "complete"){
> document.getElementById(domObj).innerHTML=ajaxObj.responseText;
> }
>}
>
>
> function GetXmlHttpObject () {
> var xmlHttp = null;
> try {
> // Firefox, Opera 8.0+, Safari, IE 7+
> xmlHttp = new XMLHttpRequest();
> } catch (e) {
> // Internet Explorer - old IE - prior to version 7
> try {
> xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
> } catch (e) {
> xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
> }
> }
> return xmlHttp;
>}
>
> getContent('theClasses','getClasses.php?key=<?=$oriClasse?>');
> //Wait ??
> getContent('theMakes','getMakes.php?key=<?=$oriClasse?>&dbvalue=<?=$oriMa
> ke?>'); //Wait ??
> getContent('theModels','getModels.php?key=<?=$oriMake?>&dbvalue=<?=$oriMo
> del?>');
>
> </script>
>
>
>
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Wait between different Calls (procedures) frank.catry@gmail.com - 2014-01-23 00:20 -0800
Re: Wait between different Calls (procedures) "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-01-23 11:06 +0100
Re: Wait between different Calls (procedures) Christoph Michael Becker <cmbecker69@arcor.de> - 2014-01-23 17:26 +0100
Re: Wait between different Calls (procedures) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-01-24 02:05 +0100
Re: Wait between different Calls (procedures) Christoph Michael Becker <cmbecker69@arcor.de> - 2014-01-24 02:44 +0100
Re: Wait between different Calls (procedures) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-01-25 12:01 +0100
Re: Wait between different Calls (procedures) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-01-24 02:54 +0100
Re: Wait between different Calls (procedures) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-01-25 18:03 +0100
csiph-web