code_test
unknown
html
5 years ago
1.3 kB
15
Indexable
<form method="post" class="myform" action=""> <input type="text" name="name" placeholder="Your Name" required><br> <input type="email" name="email" placeholder="Your Email" required><br> <textarea rows="4" cols="20" name="message" placeholder="Your Message"></textarea><br> <input type="submit" name="submit" value="Send"> <span class="output_message"></span> </form> <script> $(document).ready(function() { $('.myform').on('submit',function(){ // Add text 'loading...' right after clicking on the submit button. $('.output_message').text('Loading...'); var form = $(this); $.ajax({ url: "email.php", // ստեղ քո պհպ֊ին ես հարցում անում method: form.attr('method'), data: form.serialize(), success: function(result){ if (result == 'success'){ $('.output_message').text('Message Sent!'); } else { $('.output_message').text('Error Sending email!'); } } }); // Prevents default submission of the form after clicking on the submit button. return false; }); });
Editor is loading...