title: passing multiple parameters using Ajax(url) in c#
body: <p>Am having trouble getting multiple parameters with Ajax in MVC. I have two fields that require an input. Input field for Username and CommentText.</p>
  
  <p>I am defining these parameters in the url section of the ajax. It is working fine when I only pass one parameter(works for both when tried separately), but as soon as I try both the latter parameter does not work.</p>
  
  <p><strong>Ajax function:</strong></p>
  
  <pre><code>$(function () {
      $("#button").click(function () {
          $.ajax({
              type: "GET",
              contentType: "application/json; charset=utf8",
              url: "Home/AddComment?CommentText=" + $("#CommentText").val() + "&amp;Username=" + $("Username").val(),
              dataType: "json",
              success: function (Comment) {
                  //some function
              },
              error: function (xhr, err) {
                  //some code
              }
          });
      });
  });
  </code></pre>
  
  <p>Any ideas? Should I maybe be passing the parameters through "data" instead?</p>
  
  <p><strong>Edit:</strong>
  *<em>This is the controller that should catch these parameters.</em>*</p>
  
  <pre><code> public JsonResult AddComment(string commentText, string username)
          {
              Comment c = new Comment() { CommentText = commentText, Username = username };
              CommentRepository.Instance.AddComment(c);
              return Json(GetComments(), JsonRequestBehavior.AllowGet);
  
          }
  </code></pre>