简体   繁体   中英

want use a submit handler

I have an HTML file. I want to use submit handler that must call custom.js in custom.js the contact.php is called

Html

<div id="submit"> <button type="submit" class="btn btn-lg btn-success">Send</button></div>

jQuery

$('#submit').submit(function(e) {
       $.ajax({
           type: 'POST',
           url: 'contact.php',
           data: $('#participants-summary').serialize(),
           success: function(data) {
              alert('ajaxdone');
           }

        });
        e.preventDefault();
 });

You want the jQuery submit handler to be attached to a form. So

<div id="submit"> 

needs to become

<form id="submit">

for

$("#submit").submit(

to work

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM