Question jquery NetworkError

sdave76

New member
Joined
Apr 5, 2024
Messages
1
Programming Experience
10+
I have this strange issue that I cannot seem to resolve:
.Net 4.7.2
Basic aspx and aspx.cs file with some html, css and script (using master file)
I have a simple method that does a jquery ajax call to a REST API endpoint

For some reason when I try and call an endpoint in Azure it fails with "0 error NetworkError: A network error occurred." Any other public REST end point with same response type works fine. Both URLs work fine in Postman and normal browser request
JavaScript:
// This one does not work
 function LoadSomething(vehicle) {
     $.ajax({
         type: "GET",
         url: "https://xxxxxxxxx.azurewebsites.net/api/vehicle/getvehicle",
         async: false,
         success: function (output) {
             alert(output);
         },
         error: function (jQXHR, textStatus, errorThrown) {

             alert(jQXHR.status + " " + textStatus + " " + errorThrown);
         }
     });

// This one works 100%
 function LoadVehicle(vehicle) {
     $.ajax({
         type: "GET",
         url: "https://api.restful-api.dev/objects?id=3&id=5&id=10",
         async: false,
         success: function (output) {
             alert(output[0].name);
         },
         error: function (jQXHR, textStatus, errorThrown) {

             alert(jQXHR.status + " " + textStatus + " " + errorThrown);
         }
     });
 
Last edited by a moderator:
That's the strangest looking C# code, I've ever see. Oh wait. It's JavaScript. This is a C# forum.

Anyway, if you are doing this from a work network, some places (like mine), have nanny-ware that runs that only allows limited access to external sites, and even then, only web browsers would work, but C#, Java, Python, PowerShell, nor bash would not. We have to put in a request with VP approval to get access.

If you are doing this from your home network, try disabling all your antivirus and nanny-ware to see if you see a different behavior.

It may also be helpful to look at the network traces provided by your web browser, or a proxy tool like Fiddler or Charles. It might provide a more detailed error message.
 

Latest posts

Back
Top Bottom