title: Jquery Ajax - Return Bool?
body: <p>newbie question, trying to find out if an email sent, and show result, cant seem to get it to work.</p>
  
  <pre><code>function SendPreview() {
      var value = CKEDITOR.instances['Source'].getData();
      alert(value);
      var model = { EmailBody: value.toString(), EmailTo: $("#SendTo").val(), EmailSubject: $("#Subject").val() };
      var request = $.ajax({
          url: '/Campaign/SendPreviewEmail',
          async: false,
          type: 'POST',
          dataType: 'JSON',
          data: { model: JSON.stringify(model) },
          cache: false,
          success: function (data) {
              if (data) {
                  alert("Message Sent");
              } else {
                  alert("Message Not Sent, Please check details");
              }
          }
      });
  }
  </code></pre>
  
  <pre class="lang-c# prettyprint-override"><code>[HttpPost]
  [ValidateInput(false)]
  public bool SendPreviewEmail(string model)
  {
      var e = new EmailPreview();
      JavaScriptSerializer objJavascript = new JavaScriptSerializer();
  
      e = objJavascript.Deserialize&lt;EmailPreview&gt;(model);
      if (!string.IsNullOrEmpty(e.EmailTo) &amp;&amp; !string.IsNullOrEmpty(e.EmailSubject) &amp;&amp; !string.IsNullOrEmpty(e.EmailBody))
      {
          if (IsValidEmail(e.EmailTo))
          {
              _mailService.SendMail(account.Email, e.EmailTo, e.EmailSubject, e.EmailBody, true);
              return true;
          }
      }
      return false;
  }
  </code></pre>