jquery - Why javascript function is not running? -
i have created javascript function in html file, , in ajax success console data. there aren't showing in console, , there not error found in console.
what happen?
this code:
<!doctype html> <html> <head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <title>home</title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> </head> <body> <div class="container"> <div class="div-form"> <h1>form</h1> <fom action="#" id="ajax-form" method="post" accept-charset="utf-8"> <div class="input-group"> <label>nama:</label> <input class="form-control" type="text" name="name" placeholder="nama mu"> </div> <div class="input-group"> <label>email:</label> <input class="form-control" type="email" name="email" placeholder="email mu"> </div> <div class="input-group"> <button class="btn" name="submit" type="submit" value="submit" id="contact-submit">submit</button> </div> </form> </div> </div> <script type="text/javascript"> $(document).ready(function(e) { $("#ajax-form").submit(function(event) { /* act on event */ var jsondata = $("#ajax-form").serialize(); $.ajax({ url: 'proccess.php', type: 'post', datatype: 'json', data: jsondata, }) .done(function() { console.log("success" + data); }) event.preventdefault(); }); }); </script> </body> </html>
remember event
work here updated code
$(document).ready(function(e) { $("#ajax-form").submit(function(event) { /* act on event */ var jsondata = $("#ajax-form").serialize(); $.ajax({ url: 'proccess.php', type: 'post', datatype: 'json', data: jsondata, }) .done(function() { console.log("success" + data); }) event.preventdefault(); }); });
Comments
Post a Comment