I
info
hi.
I've got a serious issue in my code that i can't figure out. I've got
pretty big code of entire site and a bug in this very place:
aut="";
try{
zaptmp='zaloguj.php?h='+haslo+'&co='+wdp;
poljs.open('GET',zaptmp,true);
poljs.onreadystatechange=function(){
if (poljs.readyState==4) {
aut=poljs.responseText;
document.title=aut;
}
}
poljs.send(null);
}
catch(zonka){
aut="error connecting server: " +
zonk.description;
};
// alert(aut);
if(aut=="ok"){
.......
so:
- try-catch is about to authenticate user via zaloguj.php (server side
works perfect and returns right status every time- let's make it
simple:status can be "ok" or "not ok")
- if(aut=="ok"){ - there is some code to execute if the user
authentication is ok.
the problem is that if(aut... never pass - aut variable has always
empty value in that place, but document.title changes to "ok" or "not
ok" so zaloguj.php responds as it should.
if I uncomment alert above, and the script waits till i press alerts
ok button, if(aut works perfectly.
It looks like the if(aut is beeing processed before poljs get the
response. I can move if(aut inside try-catch but i don't understand
why doesn't it work right now.
If anyone could confirm or make it clear what the problem is?
thanks in advance
cac
I've got a serious issue in my code that i can't figure out. I've got
pretty big code of entire site and a bug in this very place:
aut="";
try{
zaptmp='zaloguj.php?h='+haslo+'&co='+wdp;
poljs.open('GET',zaptmp,true);
poljs.onreadystatechange=function(){
if (poljs.readyState==4) {
aut=poljs.responseText;
document.title=aut;
}
}
poljs.send(null);
}
catch(zonka){
aut="error connecting server: " +
zonk.description;
};
// alert(aut);
if(aut=="ok"){
.......
so:
- try-catch is about to authenticate user via zaloguj.php (server side
works perfect and returns right status every time- let's make it
simple:status can be "ok" or "not ok")
- if(aut=="ok"){ - there is some code to execute if the user
authentication is ok.
the problem is that if(aut... never pass - aut variable has always
empty value in that place, but document.title changes to "ok" or "not
ok" so zaloguj.php responds as it should.
if I uncomment alert above, and the script waits till i press alerts
ok button, if(aut works perfectly.
It looks like the if(aut is beeing processed before poljs get the
response. I can move if(aut inside try-catch but i don't understand
why doesn't it work right now.
If anyone could confirm or make it clear what the problem is?
thanks in advance
cac