If you were using the .jquery library, you could use the $.get() function to request a response through ajax and then handle the results as a part of the call (rather than relying on the parent.<function> setup which can be fragile.
The $.get() function can take two parameters (URL and Callback function). This is the real power of this library. It will handle making the call to the page of your choice, waiting for the response, then taking an action once the call is complete.
A typical example in jquery would be:
function checkUserName(username) {
$.get(
//url with querystring to get results
"checkuser.php?u=" + username,
//callback function when the request is complete
function(data,textResponse){
if(textResponse=="success") {
alert(data)
}
})
}
You can return whatever you like from the checkuser.php page. Simple html, json data, xml...whatever. Your "data" in the .get() function is then the thing you inspect and act upon.