title: Send an AJAX email in a Javascript funciton without using PHP
body: <p>I was handed a website to work on and I'm not very familiar with AJAX. I was hoping there was a simple solution to the URL: portion of the Ajax in order to send an email. I'd rather not use a PHP script in place of what's already there but if needed I can.</p>
  
  <p>This is for a website that's mostly bootstrapped with some simple HTML code and naming conventions are standard.</p>
  
  <pre><code>&lt;script&gt;
      $("#btnSend").click(function () {
  
          var email = $('#txtFromEmail').val();
  
          if (($('#txtName').val().length === 0) || (email.length === 0) ||
              ($('#txtSubject').val().length === 0) || ($('#txtBody').val().length === 0)) {
              alert("Please fill out all of the form.");
          } else {
              var emailModel = {
                  Name: $('#txtName').val(),
                  FromEmail: $('#txtFromEmail').val(),
                  Subject: $('#txtSubject').val(),
                  Body: $('#txtBody').val()
              };
  
              $.ajax({
                  url: "@Url.Action("Contact", "Main")",
                  type: 'POST',
                  contentType: "application/json; charset=utf-8",
                  data: JSON.stringify(emailModel),
                  success: function (result) {
                      if (result.message.length == 0) {
                          alert("Message Sent Successfully!");
                      } else {
                          alert("Message failed to send. Please try again or call the Sports Hub");
                      }
                  }
              });
          }
      });
  &lt;/script&gt;
  </code></pre>