Author Topic: Ajax returns undefined?  (Read 712 times)

0 Members and 1 Guest are viewing this topic.

Offline havenpetsTopic starter

  • Irregular
  • Posts: 28
    • View Profile
Ajax returns undefined?
« on: May 22, 2010, 10:03:45 AM »
Okay, so I am creating a Jquery registration page using "dialog".
I am using the "jquery" version of AJAX. It's pretty similar, and the problem I am having can happen to either.

Basically this is how my code is organized:
Code: [Select]
function go_ajax(formtype){
formvalue = document.getElementById(formtype).value;
$.get("/xatron/check.php?type="+formtype+"&value="+escape(formvalue), function(data) {
// TEST alert(data);
return data;
});
}
Data = httpObject.responseText

Thats the same as a "get" script in AJAX. Now, later in my code I have...
Code: [Select]
if(go_ajax('username') == 0){
// Fail
}else{
// Pass
}

Now, it will come up as "Pass" EVERYTIME because...
go_ajax('username') = undefined.

But when I do the test and do the alert above it presents to me, 0 or 1. x_X
And it alerts AFTER undefined alerts. How would I go about fixing this? :O

Anyone know? (p.s. YES, I know this is jquery BUT ajax is the exact same problem (i've tried both methods).

Thank you,
Matt