Search
 
SCRIPT & CODE EXAMPLE
 

PHP

ajax call php bootstrap validation

<form class="needs-validation" role="form" id="contact-form" method="post" novalidate>
        <input type="text" name="fullname" value="">
        <input type="email" name="email" value="">
<button type="button" id="submit">Send</button>
</form>
<script type="text/javascript">
  $(document).ready(function() {

$("#submit").click(function() {
    var form = $("#contact-form")

    if (form[0].checkValidity() === false) {
      event.preventDefault()
      event.stopPropagation()
    } else {
        var data = form.serialize();
        // console.log(data);
        $.ajax({
        type : 'POST',
        url  : '/submit.php',
        data : data,
        success :  function(data)
               {
                // console.log(data);
                    if(data.succ == 1)
                    {
                        console.log('Success');
                    }else{
                        console.log('Error');
                    }
               },
        error: function (data) {
                // console.log(data);
            }
        });
    }
    form.addClass('was-validated');

  });    
});
</script>
Comment

PREVIOUS NEXT
Code Example
Php :: reset internal pointer mysql query 
Php :: To Search Specific Post Type 
Php :: laravel save without dispatching an event 
Php :: modal align center yii2 
Php :: eval base64 decode php 
Php :: many isset posts 
Php :: refresh_ttl 
Php :: Laravel Eloquent sum of multiplied columns 
Php :: TypeError IlluminateAuthSessionGuard::login(): Argument #1 ($user) must be of type IlluminateContractsAuthAuthenticatable 
Php :: laravel ignition dark mode 
Php :: content for php.ini created manually 
Php :: m 
Php :: add variables to line in laravel notification 
Php :: php exttends 
Php :: select query with multiple where clause in php 
Php :: avoid web crawling in Laravel 
Php :: Ajouter du contenu personnalisé sous chaque article/publication WordPress 
Php :: laravel return response with headers 
Php :: how to concatenate folder name with image in php 
Php :: distance between two locations in php 
Php :: andebol 
Php :: how do i implement blockchain payments on laravel website 
Php :: Writing into the database with one click laravel 
Php :: date fomat in php 
Php :: WordPress Plugin Code Definition 
Php :: shopware redirect ot homepage 
Php :: how to get many of quensation php programming language 
Php :: WooCommerce Catalog Mode snippets 
Php :: How can I share limits across multiple fields gravity forms? 
Php :: multiple slug in route 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =