How to execute a function as well as a submit form in javascript [duplicate]

I have a javascript function which saves a canvas image as png on the server, as well as a form.

$(document).ready(function() {
    
    var lc = LC.init(document.getElementsByClassName('my-drawing')[0]);
    $('#submit_all').click(function(e) {
        e.preventDefault();
        
     var image = lc.getImage().toDataURL();
     
    $.ajax({
        type: "POST",
        url: "plugins/measurements/add.php",
        data: {
          image: image,
          uid: <?php echo $uid; ?>
        }
      });
    });
    });

The problem is when I use the e.preventDefault() function the image gets saved but the form is not submitted and when I remove it the opposite happens.
Any help on how to solve this would be greatly appreciated.