title: ASP MVC2 execute controller method in javascript
body: <p>In my ASP application I'm trying to retrieve a value from the database. From javascript I try to execute a controller method.</p>
  
  <p>Javascript</p>
  
  <pre><code>function getCapital(country) {
  //alert(country);
  var url = "~/Home/Capital";
  $.get(url, { country: country }, function (response) {
      $("#getCapital").html(response);
      alert(response);
  });
  </code></pre>
  
  <p>Controller (Home)</p>
  
  <pre><code>public string Capital(string country)
  {
     return capitalService.getCapital("Frankrijk");
  }
  </code></pre>
  
  <p>But I get no result.</p>
  
  <p>EDIT</p>
  
  <p>View</p>
  
  <pre><code>&lt;script type="text/javascript" src="/Scripts/jquery-1.4.1.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="/Scripts/World.js" &gt;&lt;/script&gt; 
  </code></pre>
  
  <p>This the output of Browser Console. So sometimes it logs the URL without an error.</p>
  
  <p><a href="https://i.stack.imgur.com/6QoGV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6QoGV.png" alt="This is the ouput "></a></p>