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 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 路易威登官网 里边的参数逆向
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决
  • ¥15 processing提取音乐节奏
  • ¥15 gg加速器加速游戏时,提示不是x86架构
  • ¥15 python按要求编写程序
  • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入
  • ¥20 XP系统在重新启动后进不去桌面,一直黑屏。