title: json success and fail response in MVC
body: <p>I'm practicing Ajax! I have a simple contact form and this is my actions :</p>
  
  <pre><code>public ActionResult Contact()
          {
              return View("Contact");
          }
  
          [HttpPost]
          public ActionResult Contact(ContactViewModel contactViewModel)
          {
              if (ModelState.IsValid)
              {
                  var contact = contactViewModel.ConvertToContactModel(); 
                  _contactRepository.Add(contact);
                  _contactRepository.Save();
                  return Json(new { msg = "Your contact Sent, I'll response soon." });
              }
              return Json("Sorry! Somthing went wrong, try again or contact again");
          }
  </code></pre>
  
  <p>and this is my View : </p>
  
  <pre><code>@model Blog.Web.UI.ViewModels.ContactViewModel 
  @{
      ViewBag.Title = "Contact";
      Layout = "~/Views/Shared/_Layout.cshtml";
  }
  
  &lt;div id="Contact"&gt;
      @using (Ajax.BeginForm("Contact", "Home", new AjaxOptions() { OnSuccess = "Success" }))
      {
  
          &lt;div&gt;
              @Html.LabelFor(c =&gt; c.Name)
              @Html.TextBoxFor(c =&gt; c.Name)
          &lt;/div&gt;
  
          &lt;div&gt;
              @Html.LabelFor(c =&gt; c.Email)
              @Html.TextBoxFor(c =&gt; c.Email)
              @Html.ValidationMessageFor(c =&gt; c.Email)
          &lt;/div&gt;
  
          &lt;div&gt;
              @Html.LabelFor(c =&gt; c.Subject)
              @Html.TextBoxFor(c =&gt; c.Subject)
          &lt;/div&gt;
  
          &lt;div&gt;
              @Html.LabelFor(c =&gt; c.Body)
              @Html.TextAreaFor(c =&gt; c.Body)
              @Html.ValidationMessageFor(c =&gt; c.Body)
          &lt;/div&gt;
          &lt;input type="submit" value="Send" /&gt;
      }
  &lt;/div&gt;
  
  &lt;script type="text/javascript"&gt;
      function Success(context) {
          if (context[0]) {
              $("#Contact").empty().html(context[1]);
          }
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>Now I wanna to show the user success or failing of contact made , what's the problem of my code that doesn't work??
  it is so interesting that my validation doesn't work in this case!
  please help me about this , thanks </p>