Ajax form does not execute on success

Ajax form does not execute on success

Hi,

I have a form that uses ajax. It is supposed to execute an addclass and append to a div upon success. The code submits the form, but does not execute on success.

$("form#mc-embedded-subscribe-form").submit(function(e)
{ e.preventDefault();
$.ajax({
type: "POST",
url: $(this).attr('action'),
data: $(this).serialize(), // serializes the form's elements.
success: function(data) {
$('#newsletterform').addClass('success').append('<div class="thanks">Thanks for Subscribing!</div>');
}
});
});

What's the issue? Thanks!