title: How do you inject urls into jquery AJAX using ASP.NET MVC?
body: <p>I'm trying to use AJAX via jquery with ASP.NET MVC, but I'm not able to hit my controller action and I think it might be because my url is not specified correctly.</p>
  
  <p>The problem is, I'm not sure what is should be!</p>
  
  <p>Say I have a controller named "Home", and an action named "AjaxAction", would the jquery look like this?</p>
  
  <pre><code>$.get("Home/AjaxAction");
  </code></pre>
  
  <p>This doesn't seem to be working for me, so I'm wondering if there's a more correct way to do this using Html helpers or something from ASP.NET MVC.</p>
  
  <p>For instance, has anyone tried doing something like this?</p>
  
  <pre><code>&lt;a href="#" 
      onclick="doSomeFunction('&lt;%= Url.Action("AjaxAction", "Home") %&gt;')"&gt;
      Click Me
  &lt;/a&gt;
  &lt;script&gt;
      function doSomeFunction(url)
      {
          $.get(url);
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>Would that work or am I barking up the wrong tree?  I've tried it myself but it's not working, but I'm not sure if it's because I'm doing something wrong or if it's because the entire approach is incorrect.</p>