• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 175
  • Last Modified:

java script ajax

hi

i trying to use ajax function whit xmlHttp.onreadystatechange=function(){....


i have no problem to get the date that i need but i can't return the data to the calling function

i have 1 function

functio xxx(){
.....
.....
 if (checkIfUserIsActive(userId) == 0){        //call to ajax func
  do samthing
 }
}

i get all the time the value undifined in the 1ts func if i add alert to 2nd func (ajax) i get the data


thenk
0
yairab
Asked:
yairab
  • 2
2 Solutions
 
strickddCommented:
With an AJAX call, since it is Asyncrhonous, the return never gets passed up the stack back to where you make the call. It creates a new thread and returns to the specified callback method.

This means, you need to check (checkIfUserIsActive(userId) == 0) by checking the AJAX return in the callback method and comparing it to 0.
0
 
leakim971PluritechnicianCommented:
0
 
leakim971PluritechnicianCommented:
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now