Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

asp mvc jquery 404

Avatar of critto
crittoFlag for United Kingdom of Great Britain and Northern Ireland asked on
JavaScript.NET ProgrammingAJAX
1 Comment1 Solution940 ViewsLast Modified:
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>');
             }
             
         }
       });
 });
})
ASKER CERTIFIED SOLUTION
Avatar of jamesbaile
jamesbaileFlag of United Kingdom of Great Britain and Northern Ireland image

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 1 Comment.
See Answers