小编Jua*_*los的帖子

仅 Firefox TypeError:“尝试获取资源时出现网络错误。”

我有一个动态加载内容的页面,并且我对后端 API 进行了多次调用,所有这些调用都具有相同的配置,如下所示:

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
  });   

Run Code Online (Sandbox Code Playgroud)

当页面加载时,调用许多这样的函数:

get_data_1(); get_data_2(); ...

后端 API 的所有响应都具有相同的输出格式(JSON)并具有相同的标头,我使用唯一的服务器(localhost),但只有某些调用出现错误,其他调用正常工作,问题仅出在 Firefox …

javascript firefox resources fetch web

7
推荐指数
1
解决办法
3万
查看次数

标签 统计

fetch ×1

firefox ×1

javascript ×1

resources ×1

web ×1