title: Jquery Ajax url to MVC controller
body: <p>I'm trying to call a controller from a function through Ajax:</p>
  
  <pre><code>$.ajax({
    url: "@Url.Action("items_status", "Part_views_index")",
    type: 'GET',
    dataType: 'json',
    error: function (xmlHttpRequest, errorText, thrownError) {
                  alert(xmlHttpRequest + "|" + errorText + "|" + thrownError);
          },
    success: function (data) {
              UpdateItemsData(data);
          }
   });
  </code></pre>
  
  <p>But this return a 404, here is the controller part:</p>
  
  <pre><code>public class Partviewsindex : Controller
  {
      // Controller for partial view 
      [HttpGet]
      public JsonResult items_status()
      {
          var chart = new getItemsStatusChart();
          var chartData = chart.GetPieChart();
          return Json(chartData);
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Any idea?</p>
  
  <p>Thanks</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>I found the problem, I needed to add Controller at the end of the controller name and the url is now formed like this in my javascript file:</p>
  
  <pre><code>$.ajax({
          url: '/Partviewsindex/items_status',
          type: 'GET',
          dataType: 'json',
          error: function (xmlHttpRequest, errorText, thrownError) {
              alert(xmlHttpRequest + "|" + errorText + "|" + thrownError);
          },
          success: function (data) {
              UpdateItemsData(data);
          }
      });
  </code></pre>
  
  <p>Thanks</p>