I'm trying to return an array of some simple information from a for each loop without success. Here is the code I'm using in two different functions.
function getUser(uname, callback) {
var u = "http://itsuite.it.brighton.ac.uk/john10/ci227/a1/whois.php?username=" + uname;
return $.get(uname, {}, callback);
}
function parseUserInfo(usrname) {
getUser(usrname, function(data) {
var x = new Array();
$(this).find("user").each(function() {
x['username'] = $(this).find("username").text();
x['firstname'] = $(this).find("firstname").text();
x['surname'] = $(this).find("surname").text();
return x;
}
}
}
All I'm getting when I use it like this:
var dat = parseUserInfo("guest");
Is Undefined when using the console.log(dat) so could someone tell me where I'm going wrong here?
Many Thanks! Oh Btw I have looked at other solutions on here and elsewhere but as yet cannot find anything that works for me, so please no 'this thread is a duplicate' or 'its been answered here' links coz that will put me back to square one and make asking this question pointless!