Link to home
Start Free TrialLog in
Avatar of critto
crittoFlag for United Kingdom of Great Britain and Northern Ireland

asked on

asp mvc jquery 404

Hi Experts.

I have an asp.net mvc application and since migrating to server, I am getting a 404 on an ajax call that works locally.

The erroro is:
<div class="content-container"><fieldset>
  <h2>404 - File or directory not found.</h2>
  <h3>The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.</h3>
 </fieldset></div>

I'm calling the following controller action in both cases:

and the javascript below:


anyone have any ideas?

[Authorize(Roles = "Role1,Role2")]
    [AcceptVerbs(HttpVerbs.Get)]
    public JsonResult SpecialistList(string specialistTypeId, string locationId)
    {
    {
      try
      {
        var query = _repository
          
            ..... load data.... 

        return Json(UserMapper.ToDto(query.ToList()));

      }
      catch (Exception ex)
      {
        // log any exceptions and return an error
        LogException(ex, HttpContext.Request);
        //return Json(ex.Message);
        return new JsonResult();
      }
    }

.....

In my view ( spark ) i have:

....

!{ Html.DropDownList ( "Location" , Locations ) }
!{ Html.DropDownList ( "SpecialistType" , SpecialistTypes ) }
!{ Html.DropDownList ( "SpecialistID" , new SelectList("Test", "test") ) }
....
	
$(function(){
  $("select#SpecialistType").change(function(){
		var location = $("select#Location").val();
        var data = $(this).val();
        var json = {specialistTypeId: data, locationId: location};
        
        $.ajax({
          type: "GET",
         url: "/Patient/SpecialistList",
         data: json,
         location: json,
         dataType: "json",
         error: function(xhr, status, error) {
           alert("error in routine: " + error );
         },
         success: function(res){
           var $dropdown = $("select#SpecialistID");
           $dropdown.find('option').remove().end();
           $dropdown.append('<option value="">..select specialist type</option>');
           for (var i = 0; i < res.length; i++) {
               $("select#SpecialistID").append('<option value="' + res[i].Id + '">' + res[i].StaffCode + '</option>');
             }
         },
       });
 });
 
  $("select#Location").change(function(){
		var location = $("select#Location").val();
        var data = $("select#SpecialistType").val();
        var json = {specialistTypeId: data, locationId: location};
        
        $.ajax({
          type: "GET",
         url: "/Patient/SpecialistList",
         data: json,
         location: json,
         dataType: "json",
         error: function(xhr, status, error) {
           alert("error in routine: " + error );
         },
         success: function(res){
           var $dropdown = $("select#SpecialistID");
           $dropdown.find('option').remove().end();
           $dropdown.append('<option value="">Select Specialist</option>');
           for (var i = 0; i < res.length; i++) {
               $("select#SpecialistID").append('<option value="' + res[i].Id + '">' + res[i].StaffCode + '</option>');
             }
             
         }
       });
 });
})

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of jamesbaile
jamesbaile
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial