Javascript AJAX function returns undefined instead of true / false
- by Josh K
I have a function that issues an AJAX call (via jQuery). In the complete section I have a function that says:
complete: function(XMLHttpRequest, textStatus)
{
if(textStatus == "success")
{
return(true);
}
else
{
return(false);
}
}
However, if I call this like so:
if(callajax())
{
// Do something
}
else
{
// Something else
}
The first is never called.
If I put an alert(textStatus) in the complete function I get true, but not before that function returns undefined.