在某些浏览器上,Ajax 调用停止

Ajax call halting on some browsers

本文关键字:Ajax 调用 浏览器      更新时间:2023-09-26

根据控制台,在商业环境中的某些PC上使用Firefox发布的Ajax调用不会发生(240个相同的安装)。如果我删除location.reload();那么 Ajax 帖子就会发生得很好。但是,浏览器不会刷新,因为它使用Ajax。

我做错了什么吗?

 select: function(start, end, allDay, jsEvent, view) {                  
                    if (userID) {                   
                        var start = moment(start).format('YYYY-MM-DD')
                        var end = start;                
                        $.ajax({
                            type: "POST",
                            cache: false,
                            url: 'http://intakecalendar/adddate.php',
                            data: 'userID='+ userID + '&start=' + end   //+ '&end=' + end <-- Providing the REAL end date makes it show on the wrong day
                        });                     
                    } //End if
                    location.reload();
            } // end select

这是一个竞争条件。您正在进行 http 调用并重新加载页面。只有一个会赢,现代浏览器,页面导航中止打开的http请求。

将重新加载移动到成功/完成处理程序。

select: function(start, end, allDay, jsEvent, view) {
  if (userID) {
    var start = moment(start).format('YYYY-MM-DD')
    var end = start;
    $.ajax({
      type: "POST",
      cache: false,
      url: 'http://intakecalendar/adddate.php',
      data: 'userID=' + userID + '&start=' + end, //+ '&end=' + end <-- Providing the REAL end date makes it show on the wrong day
      complete: function() {
        window.location.reload();
      }
    });
  } else {
    window.location.reload();
  }
}