Asynchronous Lazy Loading
<p>currently, we are using the SAP HANA Database. To get data, we will use a Node.JS-API, which we will call via AJAX, to get the advantages by async. So here is the problem:</p>

<p>We have many pages where we need the same data (e.g. customer data). To do so, I wanted to create a Library, which does the actual data calls, so that i just need to call <code>db.getCustomer([ID])</code>. In order to get a return value from AJAX, I have to set <code>async: false</code> within the AJAX call.</p>

<p>My question is now, is it possible to create a data-call-library asynchronously? Is it a good practice to encapsulate the databinding (using so called DAO)? 
I'm a bit confused, because another dev told me to just use the same AJAX-call over and over again, to not loose the async and it is a better practice anyway.</p>

<p>Here is my actual AJAX-call as an example:</p>

<pre><code>getCustomer: function( CID ) {
            var aUrl = 'http://example.com/api/customer/' + CID,
                returnData
            ;
            jQuery.ajax({
                url: aUrl,
                method: 'GET',
                dataType: 'json',
                contentType: "application/json",
                async: false,
                success: function(data) {
                    returnData = data;
                }
            });
            return returnData;
        },

// other ajax calls 
// to get the data via 1-liner
</code></pre>

<p>thank you for clarification!</p>