views:

48

answers:

1

Hi all,

I am trying to show the message updated in DB using the following code

var showtime = setInterval('redirect()',5000);
////Redirecting to DB Status /////
function redirect()
{   
 xmlhttp = GetXmlHttpObject();
 if (xmlhttp==null)
    {
     alert ("Browser does not support HTTP Request");
     return;
    }
    var url="isResultexist.php"
    xmlhttp.onreadystatechange=stateChanged;
    xmlhttp.open("GET",url,true);
    xmlhttp.send(null);
}

I am collecting the response from PHP here and using it to update the Messages on UI Problem here is it works fine 1st time when it called after 5sec but there after return the Same result even DB is updated,

This works fine with Mozilla and google chrome browser

regards hemant

+4  A: 

the IE is caching the response, so try to set an expires-header in your isResultexist.php, add a random parameter to each request or switch from get to post (post isn't cached).

oezi
Time is always a good one (http://www.php.net/manual/en/function.gettimeofday.php)or yeah, a random number would work well too.(http://us3.php.net/manual/en/function.mt-rand.php)
Dan Williams
i think the best solution is the last one i posted - a "random" parameter will be chached, too, so after some time the cache would be full of trash - and the expires-header is sometimes ignored by this dumb piece of software aka internet explorer
oezi