How can I get a button click event to fire as soon as my page loads? : <p>I've got this jQuery:</p>

<pre><code>$(document).ready(function () {
    $("body").on( "click", "#btnGetData", function() {
        var _begdate = $("#datepickerFrom").val();
        var _enddate = $("#datepickerTo").val();
        var _unit = $("#unitName").text();
        document.body.style.cursor = 'wait';

        $.ajax({
            . . .elided for brevity.
        });
    });
    $("#btnGenData").trigger('click');
});
</code></pre>

<p>I need the click event to occur as soon as the page load; I tried calling it this way, after the click function:</p>

<pre><code>$("#btnGenData").trigger('click');
</code></pre>

<p>...but it doesn't work. What am I missing?</p>
