title: Getting correct URL to make ajax call from JS file
body: <p>I am working with an ASP MVC app. I created a clients.js file that has an ajax method that calls a controller and then retrieves the data. My problem is that the URL where that page sits looks something like this:</p>
  
  <pre><code>http://my.clients.com/GST/2015-4/LEBIN/Profiles/ClientProfile/Index/79
  </code></pre>
  
  <p>In my ajax method i have</p>
  
  <pre><code>$.ajax({
    url: "ClientProfile/UpdateClient",
    context: ..
    data: ...
  }).done(function() {
    ...;
  });
  </code></pre>
  
  <p>therefore, using that format i get</p>
  
  <pre><code>http://my.clients.com/GST/2015-4/LEBIN/Profiles/ClientProfile/Index/79/ClientProfile/UpdateClient
  </code></pre>
  
  <p>But i need:</p>
  
  <pre><code>http://my.clients.com/GST/2015-4/LEBIN/Profiles/ClientProfile/UpdateClient
  </code></pre>
  
  <p>Also if i add a / before the url like this:</p>
  
  <pre><code>$.ajax({
    url: "/ClientProfile/UpdateClient",
   ...
  </code></pre>
  
  <p>It formats the URL like this:</p>
  
  <pre><code>  http://my.clients.com/UpdateClient
  </code></pre>
  
  <p>How can i obtain the correct path?, i just need to replace the <code>/Index/83</code> with the correct action <code>/UpdateClient</code> without funky replaces or logic..</p>
  
  <p><strong>ADDITIONAL INFO</strong></p>
  
  <p>The reson why i would not like to just add the whole url part.. is because /2015-4/ part might change several times</p>