Jua*_*los 7 javascript firefox resources fetch web
我有一个动态加载内容的页面,并且我对后端 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 上对于 chrome、opera 和 edge,我没有任何错误。
| 归档时间: |
|
| 查看次数: |
26246 次 |
| 最近记录: |