title: call server-side function from client-side in mvc3
body: <p>I have followed <a href="https://stackoverflow.com/questions/6151667/mvc-3-razor-call-a-server-side-function-using-jquery">this post</a>, but the only thing that works from my solution is the error message alert. :D</p>
  
  <p>My js-ajax code:</p>
  
  <pre><code>$(document).ready(function () {
      $('a').click(function (e) {
          var data = { 'id': $(this).attr("id") };
          var dataVal = JSON.stringify(data);
  
          $.ajax({
              type: "POST",
              url: "@Url.Action("ActionName", "ControllerName")", 
              contentType: "application/json; charset=utf-8",
              data: dataVal,
              dataType: "json",
              success: function (id) {
                  alert(data.d);
                  alert("yay! it works!");
              },
              error: function(id){
                  alert("haha, it doesn't work! Noob!");
              }
          });
          return false;
      });
  });
  </code></pre>
  
  <p>It is located at the end of the body, so it loads after all the other html contents are rendered.</p>
  
  <p>This is my call-back function in the controller:</p>
  
  <pre><code>[HttpPost]
  public ActionResult Hello(string id)
  {
      return RedirectToAction(id);
  }
  </code></pre>
  
  <p>and the HTML anchor tag:</p>
  
  <pre><code>&lt;a href="#" style="float:left; font-size:13px;" id="pageName"&gt;Read more&lt;/a&gt;
  </code></pre>
  
  <p>So, what I want is, upon any click of an anchor tag link, this JS to be fired and calling the function from the server-side, passing to it the value of the <em>id</em> parameter, where the call-back function will do its job (which is to call some View, according to the given id).</p>
  
  <p>Buuuuut, I am getting only "haha, it doesn't work! Noob!" alert message. :D Any suggestions ?</p>
  
  <p><strong>Update with some code</strong>
  <code>RedirectToAction</code> is a method from the framework, that redirects to another action. In this case I redirect to an action that will call me a certain view, for example this one:</p>
  
  <pre><code>public ActionResult Media()
      {
          //do some stuff here 
  
          return View();
      }
  </code></pre>