jQuery selector $(this) not working as expected
<p>When submitting an ajax request, I would like to toggle a class before send, toggle it back on error, or keep it if everything turns out ok. But the <code>$(this)</code> selector does not seem to be working and I'm not sure why. I'm using jQuery 1.4.3.</p>

<p><em>html</em></p>

<pre><code>&lt;a class="vote-down vote-down-112 state-3" data-postid="112" data-voteid="6"&gt;down&lt;/a&gt;
</code></pre>

<p><em>js</em></p>

<pre><code>$('.vote-down').click(function() {
    var voteData = '&amp;postId=' + $(this).data('postId') + '&amp;voteId=' + $(this).data('voteid');
    $.ajax({
        dataType: 'script',
        url: "myURL" + "?format=js" + voteData,
        error: function(XMLHttpRequest, textStatus, errorThrown) { $(this).toggleClass("status-3"); },
        beforeSend: function(XMLHttpRequest) { $(this).toggleClass("status-3"); }
    });
    return false;
}); 
</code></pre>
