title: 405 Not Allowed for Ajax Contact Form code
body: <p>I'm fairly new to programming in general, but I am trying to create an ajax contact form. I've have tried numerous different methods but none of them seem to be working effectively. My code is as follows:</p>
  
  <p>html/js code:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>            &lt;div class="row"&gt;
                 &lt;div class="col-sm-8 col-sm-offset-2"&gt;
                      &lt;form class="form--square form-email" id="contactformid" method="post" name="contactformid"&gt;
                          &lt;h4 class="text-center"&gt;Or you can reach us right here:&lt;/h4&gt;
                          &lt;div class="input-with-icon col-sm-12"&gt;
                              &lt;i class="icon-Business-Man" style="color:#0aaf4b"&gt;&lt;/i&gt; &lt;input id="name" name="name" placeholder="Name" required="" type="text"&gt;
                          &lt;/div&gt;
                          &lt;div class="input-with-icon col-sm-6"&gt;
                              &lt;i class="icon-Email" style="color:#0aaf4b"&gt;&lt;/i&gt; &lt;input id="email" name="email" placeholder="Email Address" required="" type="text"&gt;
                          &lt;/div&gt;
                          &lt;div class="input-with-icon col-sm-6"&gt;
                              &lt;i class="icon-Smartphone-3" style="color:#0aaf4b"&gt;&lt;/i&gt; &lt;input id="phone" name="phone" placeholder="Phone Number" required="" type="text"&gt;
                          &lt;/div&gt;
                          &lt;div class="col-sm-12"&gt;
                              &lt;textarea id="message" name="message" placeholder="Message" required="" rows="8"&gt;&lt;/textarea&gt;
                          &lt;/div&gt;
                          &lt;div class="col-sm-12"&gt;
                              &lt;button class="btn btn--primary vpe" id="submitBtn" name="submit" style="width: 100%" type="submit"&gt;SEND&lt;/button&gt;
                          &lt;/div&gt;
                          &lt;div id="feedback"&gt;&lt;/div&gt;
                      &lt;/form&gt;
                      &lt;script src="http://code.jquery.com/jquery-latest.js"&gt;
                      &lt;/script&gt; 
                      &lt;script&gt;
                                       $(document).ready(function(){
  
                                           $( "#submitBtn" ).click(function( event ) {
                                               //values
                                               var name=$('#name').val():
                                               var email=$('#email').val():
                                               var phone=$('#phone').val():
                                               var message=$('#message').val():
                                               var dataString = {"name": name, "email":email, "phone": phone, "message":message}
                                               console.log(dataString);
  
                                               $.ajax({
                                                   type:"POST",
                                                   url:"./newest.php",
                                                   data: dataString,
                                                   success: function() {
                                                       alert("Email Sent Successfully");
                                                   }
                                               });
                                           });
                                       });
                      &lt;/script&gt;
                  &lt;/div&gt;
              &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>And my php code:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php
  if(isset($_POST['name'], $_POST['email'], $_POST['phone'],$_POST['message'])){
   $name = $_POST['name'];
   $email = $_POST['email'];
   $message = $_POST['message'];
   $phone = $_POST['phone'];
   $from = 'Contact Us Page'; 
   $to = 'redwards@farmdrive.co.ke'; 
   $subject = 'Message from Contact Us ';
   
   $body = "From: $name\n E-Mail: $email\n Message:\n $message";
  
   // Check if name has been entered
   if (!$_POST['name']) {
    $errName = 'Please enter your name';
   }
   
   // Check if email has been entered and is valid
   if (!$_POST['email'] || !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
    $errEmail = 'Please enter a valid email address';
   }
   if (!$_POST['phone']) {
    $errEmail = 'Please enter your telephone number';
   }
   //Check if message has been entered
   if (!$_POST['message']) {
    $errMessage = 'Please enter your message';
   }
   
  // If there are no errors, send the email
  if (!$errName &amp;&amp; !$errEmail &amp;&amp; !$errMessage) {
   if (mail ($to, $subject, $body, $from)) {
    $result='&lt;div class="alert alert-success"&gt;Thank You! We will be in touch&lt;/div&gt;';
   } else {
    $result='&lt;div class="alert alert-danger"&gt;Sorry there was an error sending your message. Please try again later&lt;/div&gt;';
   }
  }
   }
  ?&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>As of now I am receiving a '405 Not Allowed'. Please let me know if you have any advice or suggestions. </p>