javascript - Form is not sending through ajax to php page -


i created form inputs inside of trying send via ajax call php form allow me email.

from looking @ network tab, not seeing php file email-project.php show up, unless looking in wrong location. uncertain of doing wrong. error getting unexpected token line in ajax variables:

var project-name = $("#project-name").val();

does see wrong?

<form action="" autocomplete="on" method="post" id="project-information-form">     <input type="text" class="input-borderless" id="project-name" placeholder="your name">     <input type="text" class="input-borderless" id="title-roll" placeholder="title/role">     <input type="email" class="input-borderless" id="project-email" placeholder="email address">     <input type="text" class="input-borderless" id="project-number" placeholder="phone number">     <input type="text" class="input-borderless" id="project-company" placeholder="company/url"> </div> <div class="project-input-container2">     <textarea rows="3" class="input-borderless" id="project-description" placeholder="describe project"></textarea>     <input type="text" class="input-borderless" id="project-source" placeholder="how did hear us?">     <input type="text" class="input-borderless" id="project-socialmedia" placeholder="which of our social media influenced most?">     <input type="text" class="input-borderless" id="project-humantest" placeholder="human test: day comess after thursday?"> </div>     <input type="submit" id="submit-project" value="send project inquiry"> </form> 

ajax

$(document).ready(function(){      $("#submit-project").on("click", function () {         var project_name        = $("#project-name").val();         var title_roll          = $("#title-roll").val();         var project_email       = $("#project-email").val();         var project_number      = $("#project-number").val();         var project_company     = $("#project-company").val();         var project_description = $("#project-description").val();         var project_source      = $("#project-source").val();         var project_socialmedia = $("#project-socialmedia").val();         var project_humantest   = $("#project-humantest").val();                 $.ajax({             url: "email-project.php",              type: "post",             data: {                 "project_name":         project_name,                 "title_roll":           title_roll,                 "project_email":        project_email,                 "project_number":       project_number,                 "project_description":  project_description,                 "project_source":       project_source,                 "project_socialmedia":  project_socialmedia,                 "project_humantest":    project_humantest             },             success: function (data) {                 //  console.log(data); // data object return response when status code 200                 if (data == "error!") {                     alert("unable send email!");                     alert(data);                 } else {                     $(".announcement_success").fadein();                     $(".announcement_success").show();                     $('.announcement_success').html('announcement added!');                     $('.announcement_success').delay(5000).fadeout(400);                 }             },             error: function (xhr, textstatus, errorthrown) {                 alert(textstatus + "|" + errorthrown);                 //console.log("error"); //otherwise error if status code other 200.             }         });     }); }); 

php

ini_set('display_errors', 1); error_reporting(e_all);  $project_name           = $_post['project_name']; $title_roll             = $_post['title_roll']; $project_email          = $_post['project_email']; $project_number         = $_post['project_number']; $project_description    = $_post['project_description']; $project_source         = $_post['project_source']; $project_socialmedia    = $_post['project_socialmedia']; $project_humantest      = $_post['project_humantest'];  $to = 'email'; $subject = 'project inquiry form sent'; $message = 'from: '.$project_name. "<br>" . ' email: '.$project_email. "<br>" . 'message: '.$project_description; $headers = 'from:' .$project_email . "\r\n";  if (!empty($email)) {      if (filter_var($email, filter_validate_email)) {           //should check on mail function         if (mail($to, $subject, $message, $headers)) {             echo "your email sent!"; // success message         } else {             echo "mail not sent!"; // failed message         }      } else {          //invalid email         echo "invalid email, please provide valid email address.";     }  } else {     echo "email address not filled out."; } 

enter image description here


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -