最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

http - Javascript XMLHttpRequest "NetworkError" - Stack Overflow

programmeradmin1浏览0评论

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

Essentially, I am writing an application that will run on clients external to the company intranet. Connections will pass through our single sign on server to internal services. The single sign on service is mostly transparent to the server-side application - it intercepts requests to internal services and prompts for credentials if necessary. From what I can tell, it changes the session cookie during every 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 trouble is coming in.

When the script is run, the Chrome javascript console gives the following error:

Uncaught NetworkError: A network error occurred.

The error is so vague. When I look at the Network tab in the Chrome developer tab, it shows the request, but it does not have any response data.

For curiosity, I right clicked on the request and copied it as a cURL request. I appended the session cookie to the request via the -b flag. cURL returns a HTTP 302, with a reference to a make cookie script on the server. Being a PUT request, doesn't any redirect cause the request to fail? But I'm not positive this is what is happening in Chrome/js.

Is there a way I can get more information about the error?

I am not 100% confident in the team that developed the internal services for us to use, so the use of a PUT request could indeed be impossible... the services are also still in development.

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

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

Essentially, I am writing an application that will run on clients external to the company intranet. Connections will pass through our single sign on server to internal services. The single sign on service is mostly transparent to the server-side application - it intercepts requests to internal services and prompts for credentials if necessary. From what I can tell, it changes the session cookie during every 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 trouble is coming in.

When the script is run, the Chrome javascript console gives the following error:

Uncaught NetworkError: A network error occurred.

The error is so vague. When I look at the Network tab in the Chrome developer tab, it shows the request, but it does not have any response data.

For curiosity, I right clicked on the request and copied it as a cURL request. I appended the session cookie to the request via the -b flag. cURL returns a HTTP 302, with a reference to a make cookie script on the server. Being a PUT request, doesn't any redirect cause the request to fail? But I'm not positive this is what is happening in Chrome/js.

Is there a way I can get more information about the error?

I am not 100% confident in the team that developed the internal services for us to use, so the use of a PUT request could indeed be impossible... the services are also still in development.

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

Share Improve this question asked Aug 24, 2013 at 17:02 shaddowshaddow 4351 gold badge5 silver badges20 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 13

I've run into the same problem. It seems to only happen on redirect responses. If you set your async flag to false and use a callback function then the error goes away. For example:

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

Then you'll need a function like this to listen for the response:

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

Just check the Url, like I put "https://www.google.com" instead of "http://www.google.com" and I got the same error. So, check whether you used "http" or "https" in url.

发布评论

评论列表(0)

  1. 暂无评论