I can’t see what is the problem with his chunk of code but for some reason IE7 is giving me a hard time about it
$('.vote').live('click', function() {
var post_url = base_url + 'ajax_vote' ;
var mask_id = $(this).attr('id');
var btn = $(this);
$.ajax({
type: "POST",
url: post_url,
data: "mask_id=" + mask_id,
}).done(function( msg ) {
if( msg == 'pass' ){
get_votes(mask_id);
btn.replaceWith('<span class="success">Thanks for voting</span>');
}
else{
btn.replaceWith('<span class="error">You have already voted for this.</span>');
}
});
return false;
});
Can anyone see what I’ve done to make it complain. Running jQuery 1.6.2 and this sits within an active lightbox hence the .live
For starters avoid
.live()if possible.Now for your problem:
You should use the success callback of
.ajax().