How do I include a javascript variable inside a jQuery method?
<p>The auto-pagination infinite scrolling script has a variable called <code>offset</code>. I want to pass it to the <code>scrollPagination</code> method <em>(for when it's called again)</em>, but I don't know how to do it. </p>

<p>I need to do this because the <code>offset</code> variable changes inside the <code>afterLoad</code> section, and right now the <code>offset</code> for the <code>contentPage</code> parameter is always 0.</p>

<pre><code>var offset = 0;
$('#stuffhere').scrollPagination({ 
    'contentPage': 'themes/[var.theme]/ajaxcontrols.php?page=products&amp;offset='+offset, // the page where you are searching for results
    },
    'afterLoad': function(elementsLoaded, offset){ // after loading, some function to animate results and hide a preloader div
         offset = offset + [var.homelist]; alert(offset);
    }
});
</code></pre>

<p><em>The code sample is trimmed.</em></p>

<p><strong>Update</strong></p>

<p>Here's the result I'm getting.
<img src="http://i.stack.imgur.com/9HI4N.png" alt="offset is still zero"></p>

<p>I <strong>do</strong> know variable scope. I want to pass the variable <code>offset</code> to <code>.scrollPagination({</code> and just don't know how to do it. Using <code>.scrollPagination function(offset){</code> doesn't work. </p>
