Only Firefox TypeError: "NetworkError when attempting to fetch resource."
Only Firefox TypeError: "NetworkError when attempting to fetch resource."
我有一个动态加载内容的页面,我多次调用后端 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
});
当页面加载时,调用许多这样的函数:
get_data_1();
get_data_2();
...
后端API的所有响应具有相同的输出格式(JSON)并且具有相同的headers,我使用的是唯一的服务器(localhost),但是只有一些调用会出现错误,而其他调用则可以正常工作,问题仅出现在带有 chrome、opera 和 edge 的 Firefox 上,我没有任何错误。
我找到了一些请求没有响应的原因,是我在禁用广告拦截器时安装在 Firefox 中的广告拦截器的错误,一切正常
我有一个动态加载内容的页面,我多次调用后端 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
});
当页面加载时,调用许多这样的函数:
get_data_1(); get_data_2(); ...
后端API的所有响应具有相同的输出格式(JSON)并且具有相同的headers,我使用的是唯一的服务器(localhost),但是只有一些调用会出现错误,而其他调用则可以正常工作,问题仅出现在带有 chrome、opera 和 edge 的 Firefox 上,我没有任何错误。
我找到了一些请求没有响应的原因,是我在禁用广告拦截器时安装在 Firefox 中的广告拦截器的错误,一切正常