views:

82

answers:

1

The following JQuery $.ajax() call in a .js file works locally, but not when I deploy to my ISP.

$.ajax({
  type: 'GET',
  url: 'Services/GetActivePatient',
  async: false,
  dataType: 'json',
  cache: false,
  success: function(pt) {
    Alert(pt);
  },
  error: function(xhr, ajaxOptions, thrownError) {
    alert('Error loading active patient' + 'XHR:' + xhr + ' OPTIONS:' + ajaxOptions + ' ERROR:' + thrownError);
  }
 });

My routes are:

  routes.MapRoute(
      "aspx",
      "{controller}.aspx/{action}/{id}",
      new { action = "Index", id = "" }
    );

  routes.MapRoute(
      "Default",
      "{controller}/{action}/{id}",
      new { controller = "Home", action = "Index", id = "" }
    );

  routes.MapRoute(
    "Root",
    "",
    new { controller = "Home", action = "Index", id = "" }
  );

The difference w/ the ISP is the application/site is located in a subfolder (/ipd) that is enabled as an application in IIS6.

In this call I'm getting a "404 Page Not Found" error when I view the response in Firebug.

Any thoughts appreciated.

+1  A: 

Try to change:

url: 'Services/GetActivePatient',

to

url: '<%= Url.Action("GetActivePatient", "Services") %>',

// returns /ipd/Services/GetActivePatient on the ISP
// and /Services/GetActivePatient on local server

UPDATED:

If you have separate js file then use something like this in your View:

<script type="text/javascript">
    var Services_GetActivePatient_Url = '<%= Url.Action("GetActivePatient", "Services") %>';
</script>

and then in js:

url: Services_GetActivePatient_Url,

Also look at Stephen Walther - ASP.NET MVC Tip #45 – Use Client View Data

eu-ge-ne
This url definition is part of a JQuery $.ajax() call in a .js file so I don't believe server side scripts <% ... %> will be processed.
ChrisP