jQuery(document).ready(function($) {
    $('#commentform').on('submit', function(e) {
        e.preventDefault();
        
        const formData = $(this).serialize();
        const $submitBtn = $(this).find('input[type="submit"]');
        
        $submitBtn.prop('disabled', true);
        
        $.post(acsData.ajaxurl, {
            action: 'acs_submit_comment',
            data: formData
        }, function(response) {
            if(response.success) {
                $('#commentlist').prepend(response.data);
                $('#comment').val('');
            }
            $submitBtn.prop('disabled', false);
        });
    });
});
