2

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);
});
Community
  • 1
  • 1
Frankyi
  • 21
  • 3
  • 3
    Most likely you're hitting the error callback. Figure out why you're reaching the error callback and you'll have your answer. – Kevin B Sep 03 '13 at 16:23

1 Answers1

1
  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

livin tamil
  • 69
  • 1
  • 5