Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(function(){
- $('#contact_form').submit(function(event){
- /* stop form from submitting normally */
- event.preventDefault();
- // Variable declaration
- var name = $('#name').val();
- var email = $('#email').val();
- var subject = $('#subject').val();
- var message = $('#message').val();
- // Disable submit button just after the form processed 1st time successfully.
- $('#submit').attr({'disabled' : 'true', 'value' : 'Sending...' });
- /* Post Ajax function of jQuery to get all the data from the submission of the form as soon as the form sends the values to email.php*/
- $.post("php/function/email.php", $("#contact_form").serialize(),function(result){
- //Check the result set from email.php file.
- if(result == 'sent'){
- //If the email is sent successfully, remove the submit button
- $('#submit').remove();
- //Display the success message
- $('#success').fadeIn(500);
- }else{
- //Display the error message
- $('#error').fadeIn(500);
- // Enable the submit button again
- $('#submit').removeAttr('disabled').attr('value', 'Send Message');
- }
- });
- }
- });
- );
Advertisement
Add Comment
Please, Sign In to add comment