AJAX Refresh problem with IE

Status
Not open for further replies.

oracle

New Member
Messages
430
Reaction score
0
Points
0
Hi,

I have made a small chatroom on my users page, which works wonderfully well in all browsers except for IE. On load I get last 10 messages from the server and displayed that to the users. Then as someone types in a message, the new messages are displayed.

However I guess the ajax goes fine in IE (dont have firbug so cant confirm), but the div is not updated with a new message which comes from ajax request.

It continues to show the same old set of 10 messages.

I even tried pressing F5 or pressing enter by highlighting the address bar, but the results doesn't changes in case of IE (for other browsers it works fine)

However if I try to close the IE fully and reopen the browser and reload my website, I can see the new messages in the div now.

Whats going on, its just un-explainable. How and Why is it all happening.

I know IE sucks but why do it sucks so badly.

Help please.

Imoracle
 

marshian

New Member
Messages
526
Reaction score
9
Points
0
Perhaps there's a problem in the xml object, but it's really hard to tell without any source code...
 

ASPX.King

New Member
Messages
155
Reaction score
0
Points
0
that's wierd, i had this problem in all browsers except for IE when i was trying to work with ajax. IE always works fine for me.
 

TechAsh

Retired
Messages
5,853
Reaction score
7
Points
38
IE has a different way of doing the XMLHTTP request things. It may be that you haven't implemented the IE way.

Make sure that something like the following is in the head of you page.
Code:
<script type="text/javascript">
function ajaxFunction()
{
var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  }
</script>
 
Last edited:

woiwky

New Member
Messages
390
Reaction score
0
Points
0
Like marshian said, posting the relevant code or a link to the page is most helpful.

But from the *sound* of it, I would think that you're generating xml and IE is caching it and not bothering to check if it has been updated when another request for it is made. That's something rather specific to IE, but this may not be the case as there are exceptions. You'll have to check for script errors too like TechAsh said.

In Internet Options under the Advanced tab there should be an option for notifying you about every script error, you can turn that on to see if anything is going wrong. In the spirit of MS, it probably won't give you a good idea of what the problem is, but it will at least let you know that there was one.
 

oracle

New Member
Messages
430
Reaction score
0
Points
0
Yaa that example do run, but what the hell is that site

When I presses download source code, it asks me to login even if I am logged in. If I login again, it takes me to my home page and when I navigate back to the page for this example, and presses download, It again asks me to download

Hell,

Can someone just post the example here, if you r lucky enough to download that example.

--------------------------------------------------------------------------------------------------------------

Regarding my case. I have made a small chatbox. Now when user first logs in, that chat box reads last 10 messages and populate the chat box. This is done using ajax and it goes fine.

Tha result which I return from server side is something like

n;<table><tr><td>....</td></tr></table>

where n is the chatmessageid which was last returned and rest is the chathtmlcode.

I simply seperate the two like this:

Code:
      [I]var[/I] response = xmlhttp.responseText;
      [I]var[/I] lastreturnedmessage = response.substring(0,response.indexOf(";"));
      response = response.substring(response.indexOf(";") + 1,response.length);

and then simply set the response parsed to the chat div.

This all works just great in Mozilla, Flock and even safari.

In IE I tried to alert(response), before seperating them and I found that for some hell of a reason, server is only returning this result:

n;

after n; it dont returns the html code.

I am trying to install some header parser, so that I can see if my chat application sends the paramenter to server side and if it sends what all is it sending.

Anyways someone kindly try to download the code from there and send it through.

Imoracle
 

tnl2k7

Banned
Messages
3,131
Reaction score
0
Points
0
Change the semicolon ( ; ) to some other character and see if that works; it seems like IE is interpreting it wrong. I don't know AJAX, but that would be my first move if I was having this problem.

-Luke.
 
Last edited:

oracle

New Member
Messages
430
Reaction score
0
Points
0
Well I finally killed and tracked the problem. The problem was that IE was not allowing the ajax request to load the data from the server every time. It used to load the data from the browser cache by default.

I have blogged down the same here as to how to encounter the problem and successfully bypass it.

Kindly read through:
http://abhinavsingh.com/blog/2008/06/caching-problem-with-ie-with-ajax-a-solution/

Thanks everyone for your help,
Imoracle
 

VPmase

New Member
Messages
914
Reaction score
1
Points
0
Ok, well looks like you have solved the problem. I'm going to close this thread then.
 
Status
Not open for further replies.
Top