zlogic Posted December 9, 2006 Share Posted December 9, 2006 Dear all, I am developing and app and am encountering some strange stuff. well it might be me?!?anyway here is the situation: I have a component (3rd party) and then on the onClick() eventI have the following: checkIfGroup(itemId); if (isGroup==1) { alert ("IS GROUP IF: " + isGroup); document.getElementById("divgroup").style.visibility='visible'; document.getElementById("divuser").style.visibility='hidden'; } else { alert ("IS GROUP ELSE: " + isGroup); document.getElementById("divuser").style.visibility='visible'; document.getElementById("divgroup").style.visibility='hidden'; }Now the checkIfGroup function makes an AJAX call to the database and checks if the item choosen is a group or user(not important to understand for my problem). then Once I get a response back it will set the variable isGroup variable then the if below the function call does some stuff depending on the result.Now my problem is that the if is being called before I get a response back from the server. Is there a way to tell javascript to wait a while? or is there any other way to ensure that the if is not called before I get a response back from the AJAX call?Thanks in advance!Bebil Quote Link to comment Share on other sites More sharing options...
alpine Posted December 9, 2006 Share Posted December 9, 2006 Build it all inside one function where you call checkIfGroup(itemId), then run the if-test when ajax has responded and with the result ajax brought back. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.