位置重新加载页面不起作用反应js

时间:2017-05-29 20:52:55

标签: javascript jquery ajax reactjs

我是新手做出反应,有人会帮我解释为什么F5和window.location.reload的工作方式不一样,好吗? 在formSubmit方法中将调查保存到数据库中,如果响应没问题,请通过window.location.reload重新加载页面。但是它没有得到数据,页面确实重新加载,但如果我点击F5,它会在页面上返回提交的值。

 formSubmit(guid) {
    console.log("Started");
    fetch("http://localhost:xxxx/api/survey/" + id + "/submit", {
        method:'POST'
    })
    .then((response) => {
      if(response.ok) {
         window.location.reload();
      }
      else {
        console.log('error');
      }
    })
    .catch(function(error){
      console.log('catch error');
    });
  }

0 个答案:

没有答案
相关问题