doyz51819 2013-09-03 16:21
浏览 72

jQuery $ .ajax POST请求与IE 9结果为空数组

I have a problem with my Coding, so in Firefox it works fine but in IE9 it only works for the first ~5 seconds. After that time i don't receive any POST Data anymore.

I want to load a PHP page via AJAX using the values of form inputs as POST variables. The first 5 seconds i can receive the POST on the requested page but after that i only receive an empty string.

Here is my Code:

function reload_form(){
var data = $("#formularfelder").serialize()
    $.ajax({
        type: 'POST',
        url: 'content/formular.php',
        data: data,
        success: function(msg) {
             $("#form_container").html(msg);
        }
    });
}

Is it a bug of IE9 and is there a workaround available?

It would be awesome if you could help me! :)

******EDIT****

I found the reason for this issue at this post:

Why does Internet Explorer not send HTTP post body on Ajax call after failure?

IE runs into a keep-alive timout and doesn't send the body within the POST data anymore.

To workaround this problem I send a packet in regular time intervalls (equal to the keep-alive timeout) to the server to keep the keep-alive. This will cause a little bit traffic (~200 Bytes per refresh) but it's still a more practicable workaround then disabling the keep-alive in Apache.

This was the only solution I found for this problem

For someone with the same problem here's my refreshing Code for a keep-alive timeout of 5 seconds:

var updateDiv = function ()
{
    $.ajax({type: 'POST', url: 'timeout.php'});
    yourTimer = window.setTimeout(updateDiv, 5000);
}

$( document ).ready(function() {
    var yourTimer = window.setTimeout(updateDiv, 5000);
});
  • 写回答

1条回答 默认 最新

  • dongxia527680 2015-03-17 11:38
    关注
    1. Please change your Jquery version. I also faced the same problem in IE9 when I use jquery.js version 1.10. when try it with version 1.8 the problem was solved.

    or

    1. you can simply add this line in your code $.support.cors = true;

    or

    3.you can add jquery migrate js file to resolve this. http://code.jquery.com/jquery-migrate-1.2.1.js

    评论

报告相同问题?

悬赏问题

  • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
  • ¥20 关于URL获取的参数,无法执行二选一查询
  • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
  • ¥15 marlin编译错误,如何解决?
  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集