Setting a variable outside a $.get reuqest, jQuery
<p>Trying to do what should be a simple task and cannot find a solution. I am trying to set a variable named outside of a $.get request but it does appear to be setting.</p>

<p>Here is my code:</p>

<pre><code>$(document).ready(function() {
            var totalPages
            var currentPage = 1;
            //this $.get returns a number
            $.get('getTotalPages.php', function(data) {
                totalPages = data;
            });
            //just an example of applying the result to something else
            if (currentPage &lt; totalPages) {
               ... do something...
            }
        });
</code></pre>

<p>Any ideas?</p>
