473,387 Members | 1,365 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

AJAX problem in IE (cache, maybe?)

3
Hello everyone,

I have a little script that seems to hang up in internet explorer every now and again.

Basically, I have a php page that sets the following headers:

Expand|Select|Wrap|Line Numbers
  1.    header( "Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT" );
  2.    header( "Cache-Control: post-check=1,pre-check=2" );
  3.    header( "Cache-Control: no-cache, must-revalidate" );
  4.    header( "Pragma: no-cache" );
  5.    function setExpires($expires) {  
  6.        header(  'Expires: '.gmdate('D, d M Y H:i:s', time()+$expires).'GMT');  
  7.    }  
  8.    setExpires(5);
  9.  
Additionally, in this same page, there is a call to a javascript function using onload in the body tag.

That function starts one xmlhttprequest (which should take about 20 seconds or so to do), and also starts a second xmlhttprequest which continuously updates users with the status of the first request....

It looks something like this:

Expand|Select|Wrap|Line Numbers
  1.  
  2. function startSearch(usersess)
  3. {
  4.     var url="/runsearch.php";
  5.     url=url+"?usersess="+usersess;
  6.     url=url+"&sid="+Math.random();
  7.  
  8.     searchRequest=GetXmlHttpObject();
  9.     searchRequest.onreadystatechange=function(){
  10.          searchReqChanged();
  11.     }
  12.     searchRequest.open("GET",url,true);
  13.     searchRequest.send(null);
  14.     getSorter(usersess);
  15. }
  16.  
  17. function searchReqChanged(){
  18.    if (searchRequest.readyState==4)
  19.    {     
  20.     repeatSort = 0;
  21.    }
  22. }
  23.  
  24. function getSorter(usersess)
  25. {
  26.     var usess= escape(encodeURI(usersess));
  27.     var url="update.php";
  28.     url=url+"?sid="+Math.random();
  29.     url=url+"&usess="+usess;
  30.     sorterRequest=GetXmlHttpObject();
  31.                 sorterRequest.onreadystatechange=function(){
  32.            sorterReqChanged(usess);
  33.     }
  34.     sorterRequest.open("GET",url,true);
  35.     sorterRequest.send(null);
  36. }
  37.  
  38. function sorterReqChanged(usess){
  39.    if (sorterRequest.readyState==4)
  40.    { 
  41.     document.getElementById("results").innerHTML=sorterRequest.responseText;
  42.  
  43.     if (repeatSort != -1){getSorter(usess);}
  44.                 if (repeatSort == 0){repeatSort = -1;}
  45.    }
  46. }
  47.  
The problem is, in internet explorer, whenever I navigate to the page that starts up this function, sometimes it takes FOREVER to load. It is really strange, because when I take the no-cache headers off of the page, there is no problem. Regardless of the presence of the no-cache headers, it works fine in Mozilla.

I think it has to do with the AJAX because I've tried changing startSearc() to something like a simple alert and there are no troubles..

Any help would be much appreciated, as I've been stuck on this for quite awhile now...

Many thanks.
Jan 11 '08 #1
2 1927
wpt394
3
Any ideas? I'm really having trouble with this one....
Jan 11 '08 #2
acoder
16,027 Expert Mod 8TB
I'm not sure what might be causing the problem, but you could try making a unique request instead of setting cache headers. Use the Date object and append it to the url:
Expand|Select|Wrap|Line Numbers
  1. url+new Date().getTime();
Hope that helps.
Jan 12 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: GTi | last post by:
I have a bizare Ajax POST problem. I use Ajax POST to send data to the server. The server get the POST and answer back. BUT if I POST the data once again I recieve the same answer that the first...
25
by: meltedown | last post by:
This is supposed ot be an example: http://www.ajaxtutorial.net/index.php/2006/11/30/simple-ajax-using-prototype-part-2/ It says : This example is probably the simplest example you will ever...
3
by: gyung | last post by:
Originally I had a problem with IE because I forgot to set the no-cache in the ASP pages that AJAX calls. Now that I added the headers, it works fine in IE, but still doesn't refresh properly in FF....
12
by: Mel | last post by:
I have a page with a <DIVthat gets updated every 10 seconds. The problem is that unless the browser is configured to get new pages at all times, it displays the page from cache. Is there a way...
3
by: nnaveenraju | last post by:
Hi Gurus, I am new to Ajax and JAVA. I am able to call the servlet class from the JSP page using AJAX. The servlet class is called successfully. I am processing some data and the data has...
6
by: lihao0129 | last post by:
Hi, friends, I am hoping to write a chatroom with the AJAX methodology. I knew I can set periodic refreshment from the client-side code and make the input from any visitor get updated to all...
5
by: Max | last post by:
I tried the following with Web Dev 2008 with -and- without Ajax Extension 3.5 - using IE 7 I reduced my webform1 to a Scriptmanager and an Updatepanel with 2 textbox and a button. I type something...
2
by: mndprasad | last post by:
Hi friends, Am new to AJAX coding, In my program am going to have two texbox which going to implent AJAX from same table. One box is going to retrieve the value of other and vice...
19
by: Conrad Lender | last post by:
| 5.40 Why is my Ajax page not updated properly when using an HTTP GET | request in Internet Explorer? | | Microsoft Internet Explorer caches the results of HTTP GET requests. | To ensure that...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.