【问题标题】:Internet explorer cancels ajax requestsInternet Explorer 取消 ajax 请求
【发布时间】:2019-08-08 20:43:46
【问题描述】:

我通过ajax -jquery 向服务器发出请求,这个请求返回2000多条记录(约16000条记录)

在 google chrome 中执行调用虽然花了大约 40 秒,但在 internet explorer 11 中执行被取消并且控制台中没有显示错误,它根本不会进行调用。

为了减少执行时间,我尝试调用 1500 条记录,在 google chrome 中它运行良好,但在 Internet Explorer 中只进行第一次调用:

mostrar: function() {
  this.loader = true;

  $.ajax({
    contentType: 'application/json;',
    dataType: 'json',
    type: 'POST',
    url: ('Ajax.asp?rad=' + this.radio1 + '&offsetq=' + this.limit),
    data: 1,
    success: function(e) {

      if (app.radio1 == "0")
        app.programas = e.programas;

      if (e.continuar == "1" && app.radio1 == "1") {
        app.limit = e.conteo;
        console.log(app.limit);

        console.log("va a continuar");
        //  app.programas = (e.programas);    

        app.mostrar();
      }

      app.loader = false;
    },
    failure: function(e) {
      console.log(e);
      app.loader = false;
    }
  });
}

我正在使用 vue.js,但我使用 Jquery 进行调用,因为 axios 与 Internet Explorer 11 不兼容,目前此代码适用于 chrome、edge、mozilla firefox。

在 chrome 中,他可以正确拨打电话,而在 Internet Explorer 中,他只拨打电话: https://i.imgur.com/C5wjbBc.png(铬) https://i.imgur.com/Jk4F7Tj.png (Internet Explorer)

【问题讨论】:

  • 查询是立即取消还是在一段时间后取消?
  • 第一次运行,但以后没有,这只发生在Internet Explorer中。
  • 所以只有第一个电话有效?看起来像缓存问题 - 尝试使用 headers: { Pragma: "no-cache", "Cache-Control": "no-cache" }
  • 我用两张图片更新了出版物,很明显在 chrome 中它可以正确调用,而在 Internet Explorer 中只能调用:i.imgur.com/C5wjbBc.png (chrome) i.imgur.com/Jk4F7Tj.png (Internet Explorer )
  • 似乎chrome图像被描述为IE,反之亦然。您是否尝试过按照建议设置请求标头?

标签: jquery json ajax vue.js


【解决方案1】:

也许修复contentTypedata 可以解决您的问题。尝试使用该参数执行$.ajax

$.ajax({
  contentType: 'application/json',
  dataType: 'json',
  type: 'POST',
  url: ('Ajax.asp?rad=' + this.radio1 + '&offsetq=' + this.limit),
  data: {},
  ...
});

仅供参考:如果您不需要向服务器发送任何数据,最好使用GET 而不是POST

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-10
    • 2013-09-10
    • 2012-11-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多