コードが参照したものとまったく同じように見える場合、ajax-completeコールバックを次のように変更できます。
$("#note").ajaxComplete(function(event, request, settings){
if(msg == 'OK') // Message Sent? Show the 'Thank You' message and hide the form
{
result = '<div class="notification_ok">Your message has been sent. Thank you!</div>';
$("#fields").hide();
}
else
{
result = msg;
}
/* Hide the element, alter the content, and then fade it in */
$(this).hide().html(result).fadeIn("slow");
});
これにより、エラーメッセージと成功メッセージの両方がフェードインします。
アップデート:
初めて要素をフェードさせるには、最後の行を次のように置き換えることができます。
if ($(".notification_error, .notification_ok", this).length === 0) {
$(this).hide().html(result).fadeIn("slow");
} else {
$(this).html(result);
}
私たちが行うことは、クラスnotification_errorまたはのいずれかを持つen要素があるかどうかをチェックすることですnotification_ok。そうでない場合(初めて)はフェードインし、そうでない場合はコンテンツを更新します。