• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 174
  • 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

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

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