<script> $(document).ready(function() { $("#submit").click(function() { var firstName = $("#firstName").val(); var lastName = $("#lastName").val(); var email = $("#email").val(); var message = $("#message").val(); if(firstName==''||lastName==''||email==''||message=='') { alert("Please fill all fields."); return false; } $.ajax({ type: "POST", url: "submission.php", data: { firstName: firstName, lastName: lastName, email: email, message: message }, cache: false, success: function(data) { alert(data); }, error: function(xhr, status, error) { console.error(xhr); } }); }); }); </script>
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter