jQuery post works on load, but not on click
<p>I first implemented the following snippet to show a "hi" alert and do a jQuery post at "document ready". This first step worked fine. I then added a couple of lines to execute the block only on-click of a  tag. 
Now the "hi" alert works as expected (only after I click on the link), however the post returns an 'error, the post didn't work' and doesn't complete as expected. To reiterate, if I remove the 2 lines flagged with /<em>*</em>/ below, the code works just fine (immediately after the page loads). Any ideas why?</p>

<pre><code>$(document).ready(function(){
    $('a.postlink').click(function() {    /*** post works if I remove this line ***/
    alert("hi");
    jQuery.post("http://myurl", 
            {registration_id: 'device1', command: 'MESSAGE', message: 'Hello', longMessage: ''},
       function(data) {
         alert("ok");
       })
       .error(function() {
        alert("error, the post didn't work");
        });
    });                                   /*** and this line ***/
});
</code></pre>
