troubleshooting Question

mvc webapi with jquery ajax

Avatar of ITsolutionWizard
ITsolutionWizardFlag for United States of America asked on
ASP.NETjQueryAJAX
2 Comments2 Solutions14 ViewsLast Modified:
I have super simple webapi call. and when I use aspx/c#, everything is working.
so I try to use ajax jquery to call. and I always get error, but it does not tell me the error.

I also test it with postman using get or post method. They are still working on postman.
so I guess what I need to do with the code below when postman is working....


<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
     <script type="text/javascript">                  
               
         function GetFleetList()
         {
            $.ajax({
               type: "GET",
               url: "https://www.test.com/api/api/Fleet/GetFleetListTestGet?type=json",                            
               dataType: "json",
               contentType: "application/json;charset=utf-8",
               success: function ()
                {
                            alert("Success")
                },
                error: function (request, message, error)
                {
                              alert("Error" + error + " " + message + " " );
                }
           });
         }
    </script>


[HttpGet]
        [Route("api/Fleet/GetFleetListTestGet")]
        public List<Domain.Fleet> GetFleetListTestGet()
        {
            #region mapping parms
            _fleet.FleetMasterType = "Tow";
            #endregion
            return _masterFleet.GetFleetList(_fleet);
        }
SOLUTION
Zvonko
Systems architect
Join our community to see this answer!
Unlock 2 Answers and 2 Comments.
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 2 Answers and 2 Comments.
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