title: How to prevent Ajax redirects to another page in Asp.net Mvc 5
body: <p>I have two forms in a single page.One of them is for adding comment, the other one is the main blog content as follows.</p>
  
  <p>My aim is to have blog page with adding comment functionality.When user adds a comment , I want to post the comment another controller using ajax.When providing this functionality,I want user stay at the same page and update comments partial view at the page.However I couldn't achieve this with the codes below.</p>
  
  <p><strong>Main Blog Content</strong></p>
  
  <pre><code>@model WforViolation.Models.Violation
  
  @{
      ViewBag.Title = "Details";
  }
  
  
  &lt;h1&gt;@Model.Title&lt;/h1&gt;
  &lt;p class="lead"&gt;
      Posted by @Model.CreatorUser.UserName&lt;a href="#"&gt;&lt;/a&gt;
  &lt;/p&gt;
  &lt;hr&gt;
  &lt;!-- Date/Time --&gt;
  &lt;p&gt;&lt;span class="glyphicon glyphicon-time"&gt;&lt;/span&gt; Posted on @Model.CreationDateTime &lt;span class="glyphicon glyphicon-flag"&gt;&lt;/span&gt; @Model.Severity Severity &lt;span class="glyphicon glyphicon-comment"&gt; &lt;/span&gt; @Model.Comments.Count Comments &lt;/p&gt;
  &lt;p&gt;&lt;span class="glyphicon glyphicon-eye-open"&gt; People Viewed&lt;/span&gt;&lt;/p&gt;
  &lt;hr&gt;
  &lt;!-- Preview Image --&gt;
  &lt;img class="img-responsive" src="@Model.Picture.FirstOrDefault().MediumPath" alt=""&gt;
  &lt;hr&gt;
  &lt;!-- Post Content --&gt;
  &lt;p class="lead"&gt;@Model.Title&lt;/p&gt;
  &lt;p&gt;@Model.Description&lt;/p&gt;
  
  &lt;hr&gt;
  &lt;!-- Blog Comments --&gt;
  &lt;!-- Comments Form --&gt;
  @Html.Partial("_AddComment", new WforViolation.Models.CommentViewModel() { ViolationId=Model.Id,Content=""})
  &lt;hr&gt;
  &lt;!-- Posted Comments --&gt;
  &lt;!-- Comment --&gt;
  @Html.Partial("_Comments",Model)
  </code></pre>
  
  <p><strong>Add Comment View</strong></p>
  
  <pre><code>@model WforViolation.Models.CommentViewModel
  &lt;div class="well"&gt;
      &lt;h4&gt;Leave a Comment:&lt;/h4&gt;
  
      @using (Ajax.BeginForm("AddComment", "Comment", null, new AjaxOptions
      {
          HttpMethod = "POST",
          OnSuccess = "SuccessMessage",
          OnFailure = "FailMessage"
          //UpdateTargetId = "resultTarget"
      }, new { id = "MyNewNameId", role = "form" })) // set new Id name for  Form
      {
          @Html.AntiForgeryToken()
          &lt;div class="form-group"&gt;
              @Html.TextAreaFor(model =&gt; model.Content, new { @rows = 3 })
          &lt;/div&gt;
          &lt;button type="submit" class="btn btn-primary"&gt;Submit&lt;/button&gt;
          @Html.HiddenFor(model=&gt;model.ViolationId)
      }
      &lt;/div&gt;
  &lt;script&gt;
      //\\\\\\\ JS  retrun message SucccessPost or FailPost
      function SuccessMessage() {
          alert("Succcess Post");
      }
      function FailMessage() {
          alert("Fail Post");
      }
  &lt;/script&gt;
  </code></pre>
  
  <p><strong>My Comment Controller</strong></p>
  
  <pre><code>  [HttpPost]
      public ActionResult AddComment(CommentViewModel commentViewModel)
      {
           Comment comment = new Comment();
           var userID = User.Identity.GetUserId();
  
          if (!string.IsNullOrEmpty(userID))
          {
              var manager = new UserManager&lt;ApplicationUser&gt;(new UserStore&lt;ApplicationUser&gt;(context));
              var currentUser = manager.FindById(User.Identity.GetUserId());
              comment.ApplicationUser=currentUser;
          }
          var violationId = commentViewModel.ViolationId;
          Violation violationCommentedOn = context.Violations.Where(x =&gt; x.Id == violationId).FirstOrDefault();
          comment.Violation = violationCommentedOn;
          context.Comments.Add(comment);
          context.SaveChanges();
          var result = Json(
                         new
                         {
                             Success = true,//success
                             StatusMessage = "Object created successfully"
                         });
          return result;
      }
  </code></pre>
  
  <p>When I added a comment it redirects me to another page called localhost/Comment/AddComment its content is just the Json. 
  Is it ever possible to just retrieve JsonResult and stay at the same page ?</p>
  
  <p>Or I cant post a form data using ajax and not redirecting to another page? </p>
  
  <p>I know there are similar questions but I couldn't find the exact answer.
  Any help is appreciated.</p>