troubleshooting Question

asp mvc jquery 404

Avatar of critto
crittoFlag for United Kingdom of Great Britain and Northern Ireland asked on
JavaScriptAJAX.NET Programming
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>');
             }
             
         }
       });
 });
})

Open in new window

ASKER CERTIFIED SOLUTION
jamesbaile

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

Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros