title: jQuery Ajax Call returns error : ASP.NET MVC
body: <p>"HomeController.cs" - this is my controller class.
  "ForgotPassword" - this is the action result method in the above class.</p>
  
  <pre><code>    [HttpPost]
      public ActionResult ForgotPassword(string EmailID)
      {
          SendMail(EmailID);
          return View();
      }
  </code></pre>
  
  <p>In SendMail() function, I am sending a verification link to the passing EmailID.
  I am calling this method via jQuery Ajax Method like below:</p>
  
  <pre><code>    $('#btnSubmit').click(function (e) {
  
              var emailRegex = new RegExp(/^([\w\.\-]+)@@([\w\-]+)((\.(\w){2,3})+)$/i);
              //var emailRegex = new RegExp(/^([\w-\.]+)@@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/);
              var emailAddress = $("#txtEmail").val();
              //alert(emailAddress);
              var valid = emailRegex.test(emailAddress);
              if (!valid) {
                  alert("Please Enter Valid Email address");
                  return false;
              } else {
                  alert(emailAddress);
                  //return true;
                  $.ajax({
                      url: '@Url.Content("~/Home/ForgotPassword")',
                      async: false,
                      type: "POST",
                      data: JSON.stringify({ 'EmailID': emailAddress }),
                      dataType: "json",
                      contentType: "application/json; charset=utf-8",
                      error: function (response) {
                          alert("Error");
                          alert(JSON.stringify(response));
                          //$("#errMsg").css('background', 'red');
                          //$("#errMsg").html(data.Message);
                      },
                      success: function (response) {
                          //$("#errMsg").css('background', 'green');
                          //$("#errMsg").html("Mail Sent");
                          alert(JSON.stringify(response));
                      }
  
                  });
              }
          });
  </code></pre>
  
  <p>This is my View:</p>
  
  <pre><code>  &lt;input type="text" name="EmailID" id="txtEmail" width="600" /&gt;
    &lt;input type="submit" name="btnSubmit" id="btnSubmit" value="Send" /&gt;
  </code></pre>
  
  <p>I am calling this method when button click of "btnSubmit".</p>
  
  <p>Everything is working fine. The SendMail() function is called and the mail is also send to the passing mailid. But I am getting error in the jQuery Ajax.</p>
  
  <pre><code>  error: function (response) {
                          alert("Error");
                          alert(JSON.stringify(response));
                          //$("#errMsg").css('background', 'red');
                          //$("#errMsg").html(data.Message);
                      },
  </code></pre>
  
  <p>I want to display the successful message in the view. But getting error. What is actually the problem? How to solve this?</p>