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
https://forums.phpfreaks.com/topic/202576-ajax-returns-undefined/
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.