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

crittoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jamesbaileCommented:
Id suspect that the URL of your ajax call is now invalid

$.ajax({
          type: "GET",
         url: "/Patient/SpecialistList",

Can you type /patient/specialistList in your browser?

Also in MVC 2.0 GET JSON requests are disabled by default - you have to use a POST given that security is important to you I'd recommend changing to using POSTs
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.