I'm still trying to get my head around local and global scope in JavaScript

Take the following block of code:

Code:
$(document.forms.adminError).submit(function () {
        
        sessionStorage.removeItem("errorReport");

        var $errorReport, $message, $content, $result, $store, $thisFun;
        
        $store = window.sessionStorage;

        $message = [];

        $content = "";

        $errorReport = document.forms.adminError.errorReporting.checked;

        if ($errorReport) {

            //start the ajax
            $.ajax({
                //this is the php file that processes the data and send mail
                url: 'http://' + document.domain + '/pin*****-cms/inc/admin/error_reporting_yes.php',

                //GET method is used
                type: "GET",

                //pass the data        
                data: $content,

                dataType: "text",

                // data type
                // dataType: "html",
                //Do not cache the page
                cache: false,

                //success
                success: function ($result) {

                    if($result != "") {
                        
                        $message.push("\n All errors will now be recorded in the errors.txt file");
                        
                        
                    }

                }// End success

            })


        } else {

            //start the ajax
            $.ajax({
                //this is the php file that processes the data and send mail
                url: 'http://' + document.domain + '/pin*****-cms/inc/admin/error_reporting_no.php',

                //GET method is used
                type: "GET",

                //pass the data        
                data: $content,

                dataType: "text",

                // data type
                // dataType: "html",
                //Do not cache the page
                cache: false,

                //success
                success: function ($result) {
                    
                    if($result != "") {
                     
                       $message.push("\n No errors will be recorded in a file");

                    }
                  
                  }// End success

            })


        } // end if errorReport






   if ($message.length === 0) {

            alert($message);
            
        } else {

            null;

        }
        
        




        return false;

    });


}); // End document ready
Is there anyway can take the values from the AJAX functions and use them at the end of the code as I have written above?

I tried local storage but that didn't work