title: How to send data from javascript to ASP.NET MVC controller using URL
body: <p>I need some help. I write little app using ASP.NET MVC4 with JavaScript and Knockout and I can't send data from javascript to MVC Controller and conversely. For example, the part of JS looks like that:</p>
  
  <h2>JavaScript</h2>
  
  <pre class="lang-js prettyprint-override"><code>self.Employer = ko.observable();
  self.AboutEmployer = function (id) {
              $.ajax({                    
                      Url.Action("GetEmployer", "Home")
                      cache: false,
                      type: 'GET',
                      data: "{id:" + id + "}",
                      contentType: 'application/json; charset=utf-8',
                      dataType: "json",
                      success: function (data) {
                          self.Employer(data);
                      }
                  }).fail(
                  function () {
                      alert("Fail");
                  });
           };
  </code></pre>
  
  <p>In ASP.NET MVC Home Controller I'm getting employer by ID and return it as Json:</p>
  
  <h2>C#</h2>
  
  <pre class="lang-cs prettyprint-override"><code>public JsonResult GetEmployer(int id)
      {
          var employer = unit.Repository&lt;Employer&gt;().GetByID(id);
          return Json(employer, JsonRequestBehavior.AllowGet);
      }
  </code></pre>
  
  <p>My View return another Controller (Home/KnockOutView). My View also gets another objects and depending what recieve, has different look:</p>
  
  <h2>HTML</h2>
  
  
  
  <pre class="lang-html prettyprint-override"><code>...
  &lt;b&gt;About Company: &lt;/b&gt;&lt;a href="#" data-bind="click: $root.AboutEmployer.bind($data, Vacancy().EmployerID)"&gt;
  &lt;span data-bind="    text: Vacancy().Employer"&gt;&lt;/span&gt;&lt;/a&gt;
  &lt;div data-bind="if: Vacancy"&gt;
      &lt;div id="VacancyDescription"&gt;&lt;span data-bind="text:DescriptionShort"&gt;&lt;/span&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;div data-bind="if: Employer"&gt;
      &lt;div data-bind="text: Employer().EmployerDescription"&gt;&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Everything works great, I receive Vacancy and Employer objects in JS and show it in HTML using Knockout, but my URL all time still the same!!! <strong>But I want to change URL all time, when i'm getting Vacancy or Employer.</strong> 
  For example, if I want to get Employer, using method GetEmployer, URL should looks like that: ~/Home/GetEmployer?id=3
  If I change this string of Code 
  <code>Url.Action("GetEmployer", "Home")</code> at <code>url: window.location.href = "/home/GetEmployer?id=" + id</code> URL will be changed, but Controller returns me an Json object and shows it in window in Json format.
  Help me, please, to change URL and get information in Controller from URL.
  Thanks.</p>