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

javascript - Only Firefox TypeError: "NetworkError when attempting to fetch resource." - Stack Overflow

programmeradmin3浏览0评论

I have a page which loads content dynamically, and I make several calls to backends API's all these calls have the same configuration, like this:

function get_data_1(){
  var data = {
    type: "home"    
  };
  
  fetch('../backend/get/slider.php',  {
      method: 'POST',      
      credentials: 'same-origin',
      body: JSON.stringify(data),
      headers:{
        'Content-Type': 'application/json'
      }
    })
    .then(function(response) {      
      return response.json();
    })
    .then(function(response) {            
      if( response.success ){
       //here proceses de code
      } else {               
       //here proceses de code if not success response
      }
    })
    .catch( function(error){      
      console.error(error);
      //Here is where the error catch and show the error: NetworkError when attempting to fetch resource
  });   

When the page load, call many functions like this:

get_data_1(); get_data_2(); ...

All the responses of the backend API have the same output format (JSON) and have the same headers, I'm using an only server (localhost), but only some calls get the error and others work fine, the problem is only with Firefox with chrome, opera, and edge I no have any error.

I have a page which loads content dynamically, and I make several calls to backends API's all these calls have the same configuration, like this:

function get_data_1(){
  var data = {
    type: "home"    
  };
  
  fetch('../backend/get/slider.php',  {
      method: 'POST',      
      credentials: 'same-origin',
      body: JSON.stringify(data),
      headers:{
        'Content-Type': 'application/json'
      }
    })
    .then(function(response) {      
      return response.json();
    })
    .then(function(response) {            
      if( response.success ){
       //here proceses de code
      } else {               
       //here proceses de code if not success response
      }
    })
    .catch( function(error){      
      console.error(error);
      //Here is where the error catch and show the error: NetworkError when attempting to fetch resource
  });   

When the page load, call many functions like this:

get_data_1(); get_data_2(); ...

All the responses of the backend API have the same output format (JSON) and have the same headers, I'm using an only server (localhost), but only some calls get the error and others work fine, the problem is only with Firefox with chrome, opera, and edge I no have any error.

Share Improve this question asked Jun 25, 2020 at 15:21 Juan CarlosJuan Carlos 3231 gold badge3 silver badges8 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 10

I found the reason why some request has not a response, is a bug with the ad blocker that I have installed in Firefox when I disable the ad blocker, all works fine

发布评论

评论列表(0)

  1. 暂无评论