Jump to content

Ajax returns undefined?


havenpets

Recommended Posts

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:

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

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

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.