I am returning an object in function but it returns undefined why? here is my code
parseXML = function (xml) {
        return {
            lon  : $(xml).find('GEOCODE').find("LOC").attr('lon'),
            lat  : $(xml).find('GEOCODE').find("LOC").attr('lat'),
            x    : $(xml).find('GEOCODE').find("LOC").attr('x'),
            y    : $(xml).find('GEOCODE').find("LOC").attr('y')
        };
    },
    searchRoute = function () {
        var userloc, dest; 
        userloc = cityattr.init(from, to, fromurl, parseXML);
        //dest    = cityattr.init(from, to, fromurl, parseXML);
        console.log(userloc);
    };
Update
When I do console.log() inside parseXML then it returns correct object
parseXML = function (xml) {
        var obj = {
            lon  : $(xml).find('GEOCODE').find("LOC").attr('lon'),
            lat  : $(xml).find('GEOCODE').find("LOC").attr('lat'),
            x    : $(xml).find('GEOCODE').find("LOC").attr('x'),
            y    : $(xml).find('GEOCODE').find("LOC").attr('y')
        };
        console.log(obj);
    },
Update 2
still return undefined
parseXML = function (xml) {
        return {
            lon  : $(xml).find('GEOCODE').find("LOC").attr('lon'),
            lat  : $(xml).find('GEOCODE').find("LOC").attr('lat'),
            x    : $(xml).find('GEOCODE').find("LOC").attr('x'),
            y    : $(xml).find('GEOCODE').find("LOC").attr('y')
        };
    },
here is code for cityattr
var Xml = function () {
var to, from, url, result,
    init = function (fromaddress, toaddress, link, callback) {
        from    = fromaddress;
        to      = toaddress;
        url     = link;
        requestXml(callback);
    },
    requestXml = function (callback) {
        $.ajax({
            type: "GET",
            url: url,
            dataType: "xml",
            success: callback
        });
    },
    getResult = function () {
        return result;
    };
 return {
    init        : init,
    getResult   : getResult
 };
};
 
    