Javascript XMLHttpRequest "NetworkError"

I am inexperienced in javascript and web development in general. The project I am working on is part of the overall training program of the company. We were instructed to use Google Chrome as the primary testing browser.

In essence, I am writing an application that will run on external clients within the company intranet. Connections will go through our single server sign for internal services. A single-sign service is mostly transparent to the server application — it intercepts requests to internal services and requests credentials, if necessary. From what I can tell, it changes the session cookie during each request sent.

I have established connections to services using HTTP GET and POST connections. However, there is one service that requires an HTTP PUT request. This is where the problem arises.

When running the script, the Chrome javascript console throws the following error:

Uncaught NetworkError: A network error occurred. 

The mistake is so vague. When I look at the "Network" tab in the "Chrome Developer" tab, it shows a request, but it has no response data.

For curiosity, I right-clicked on the request and copied it as a cURL request. I added a session cookie to the request via the -b flag. cURL returns HTTP 302 with a link to a make cookie script on the server. Being a PUT request, doesn't the request redirect to failure? But I'm not sure if this is what happens in Chrome / js.

Is there any way to get additional error information?

I am not 100% sure of the team that developed the internal services for us, so the use of the PUT request may indeed be impossible ... the services are also under development.

To be clear, a common problem is that I need this PUT request to go through our SSO application, if possible.

+7
javascript put google-chrome single-sign-on
source share
1 answer

I ran into the same problem. This seems to only happen when redirecting responses. If you set the flag of the asynchronous value to false and use the callback function, the error will disappear. For example:

 xmlhttp.open("GET","http://google.com", false); 

Then you need a function to listen to the answer:

 xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { // do stuff here } } 
+11
source

All Articles