in

Bootstrap 5 form validate and ajax post


ajax post not working. I really need a lot of help with this. Is there no way to use ajax post along with bootstrap form validation?

(function () {
  'use strict'
  var forms = document.querySelectorAll('#contact_form')
  Array.prototype.slice.call(forms)
    .forEach(function (form) {
      form.addEventListener('submit', function (event) {
        if (!form.checkValidity()) {
          event.preventDefault()
          event.stopPropagation()
        } else {
            $.ajax({
            type: 'post',
            url: 'post.php',
            data: $('#contact_form').serialize(),
            success: function () {
              alert('form was submitted');
            }
          }) }
        form.classList.add('was-validated')
      }, false)
    })
})()



Source: https://stackoverflow.com/questions/70552245/bootstrap-5-form-validate-and-ajax-post

Using .filter() for React’s useState setter within a .forEach() loop

Dummy Amazon clone with Bootstrap and React