Jump to content

ajax and js question


zlogic

Recommended Posts

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() event

I 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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.