title: Passing a parameter from JavaScript to a controller
body: <p>I am trying to pass a string value to a create item dialog, and am not sure on how to do it.</p>
  
  <p>This is the code in my view:</p>
  
  <p><strong>JavaScript:</strong></p>
  
  <pre><code>function newRoute() {
      $.ajax({
          url: '@Url.Action("Create")',
          success: function (data) {
              if (data == "success") //successfully created the new route
                  window.location.href = '@Url.RouteUrl(ViewContext.RouteData.Values)'
              else
                  $.facybox(data); // there are validation errors, show the dialog w/ the errors
          }
      });
  }
  </code></pre>
  
  <p><strong>View:</strong></p>
  
  <pre><code>&lt;td&gt;@route&lt;/td&gt;
  &lt;td&gt;
      &lt;a href="javascript:newRoute();" class="button"&gt;Add&lt;/a&gt;
  &lt;/td&gt;
  </code></pre>
  
  <p><strong>Controller</strong>:</p>
  
  <pre><code>public ActionResult Create(string routeName = "")
      {
          PopulateRouteInfoViewBag();
  
          var newRoute = new RouteInformation();
  
          newRoute.Name = routeName;
  
          return View(newRoute);
      }
  </code></pre>
  
  <p>I'm trying to take the value in @route and pass it over to the Create controller to have my dialog pop up with the passed in string value.</p>