javascript - PHP sendmail form is sending blank e-mail, how can I fix java script? -


i had problem day sendmail.php. first had proble not receive e-mail fix start receive e-mail blank. undestand problem wasn't php code or html code, problem java script wich attached contact-form.

var form = $('#main-contact-form'); form.submit(function(event){     event.preventdefault();     var form_status = $('<div class="form_status"></div>');     $.ajax({         url: $(this).attr('action'),         beforesend: function(){             form.prepend( form_status.html('<p><i class="fa fa-spinner fa-spin"></i> email sending...</p>').fadein() );         }     }).done(function(data){         form_status.html('<p class="text-success">thank contact us. possible  contact you</p>').delay(3000).fadeout();     }); }); 

this code sending blank e-mail. read answer similar problem , understand should use this;

var form = $('.contact-form'); form.submit(function () {     $this = $(this);     $.post($(this).attr('action'),$(this).serialize(), function(data) { 

when changed recommended code code start receive e-mail name topic , message after clicking "send now" botton page turn white blank instead of giving message "thank contact us. possible contact you"

so think couldn't combine correct code mine. can me add $.post($(this).attr('action'),$(this).serialize(), function(data) { scrpt? in advance

you can use code 2 changes, add "method" ajax request, , data send server. make sure you're working post values in php file

    var form = $('#main-contact-form'); form.submit(function(event){     event.preventdefault();     var form_status = $('<div class="form_status"></div>');     $.ajax({         url: $(this).attr('action'),         method: 'post',         data: $(this).serialize(),         beforesend: function(){             form.prepend( form_status.html('<p><i class="fa fa-spinner fa-spin"></i> email sending...</p>').fadein() );         }     }).done(function(data){         form_status.html('<p class="text-success">thank contact us. possible  contact you</p>').delay(3000).fadeout();     }); }); 

Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -