在ubuntu chrome浏览器上没有定义fetch()函数

时间:2016-05-19 12:44:39

标签: javascript ubuntu firefox chromium

我用js和php编写了一个脚本,它使用了fetch(url)函数。在windows10中它适用于firefox 46和chrome 50都可以正常工作。当我移动到ubuntu时,它给了我一个关于chrome的“fetch is not defined”错误,在firefox上它给我一个json解析错误,当我获取url然后尝试response.json()它。 铬支持fetch()?并且相同版本的firerox(46.0.1)上的相同功能是否可能在Windows 10和ubuntu上的工作方式不同?

**编辑添加代码**

function getStudioData() {
  var url='../sitSt.json';
  fetch(url).then(function(response) {
    return response.json();
  }).then(function(data) {
    putStData(data);              // function that displays the fetched datas
  }).catch(function(err) {
      console.log ('ERRORE ', err);
  })
}

2 个答案:

答案 0 :(得分:0)

https://developer.mozilla.org/en/docs/Web/API/Fetch_API

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" > <StackPanel> <TextBox Text="{Binding Object1.Content}" /> <TextBox Text="{Binding Object2.Content}" /> <TextBox Text="{Binding Object4.Content}" /> </StackPanel> </Grid> 方法仍然是实验性的,并且不适用于每个&#34;伟大的&#34;浏览器(如FF)。您可以在我上面发布的链接中看到浏览器兼容性。

问候

答案 1 :(得分:0)

然后你可以使用polyfill