Hält zu sagen, Ergebniseigenschaft ist nicht definiert. Warum?

Hier ist mein Objekt und ich habe alle Eigenschaften und Funktionen definiert, aber es gibt mir immer noch diesen Fehlerresult is not defined.

Hier ist mein Code

var Xml = {
    to      : null,
    from    : null,
    url     : null,
    result  : null,  //<--- I defined result here

    init: function (fromaddress, toaddress, link) {
        from    = fromaddress;
        to      = toaddress;
        url     = link;

        this.requestXml();
        return this;
    },

    requestXml: function () {
        $.ajax({
            type: "GET",
            url: url,
            dataType: "xml",
            success: this.parseXml
        });
    },

    parseXml: function (xml) {
        console.log('xml: ' + $(xml));
        result = $(xml); //<--- Assigning value to result here
    },

    getResult: function () {
        console.log('Result: ' + result); // <--- Here is says result is not defined
        return result;
    }
};

Wie kann ich dieses Problem lösen?

Aktualisieren

Ich rufe unten getResult () auf

var Route = {
fromurl : null,
tourl   : null,
from    : null,
to      : null,

init: function (fromaddress, toaddress) {
    from        = fromaddress;
    to          = toaddress;
    fromurl     = 'http://demo.com/url'+fromurl;
    tourl       = 'http://demo.com/url'+tourl;

    Route.searchRoute();
},

searchRoute: function () {
    var xml = Xml.init(from, to, fromurl);
    console.log(xml.getResult()); //<---- calling getResult();
}

 };

Antworten auf die Frage(3)

Ihre Antwort auf die Frage