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
https://forums.phpfreaks.com/topic/30026-ajax-and-js-question/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.