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);
});