Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-29-2009, 03:49 PM   PM User | #1
sybil6
Regular Coder

 
Join Date: Jul 2006
Posts: 399
Thanks: 33
Thanked 7 Times in 7 Posts
sybil6 can only hope to improve
function doesnt get called in ie

i am using this function to permanently call from a database a string wich represent a background color value so i can get a permanent redraw but the function doesnt get called in ie. any thoughts appreciated

Code:
var p=new xhr()
function getajax(){
p.open('get',"pid_01_ajax_query.php?",true)
p.send(null)
p.onreadystatechange=function(){
   if (p.readyState == 4) {
  var div=document.getElementById("thediv").style.backgroundColor=p.responseText;
 //alert("o")
setTimeout('getajax()',100)
             }
   }
}

getajax()
sybil6 is offline   Reply With Quote
Old 03-29-2009, 04:21 PM   PM User | #2
bdl
Regular Coder

 
Join Date: Apr 2007
Location: Camarillo, CA US
Posts: 590
Thanks: 4
Thanked 83 Times in 82 Posts
bdl is an unknown quantity at this point
This does work in Mozilla/Firefox, Safari or Opera?

Can we see the 'xhr' class? Does it test for browser type and return the correct XMLHttpRequest or ActiveXObject?

Try changing the method order to open, onreadystatechange, send.

BTW, the setTimeout call should simply reference the function name, e.g. 'getAjax', not 'getAjax()'.
bdl is offline   Reply With Quote
Old 03-29-2009, 04:25 PM   PM User | #3
sybil6
Regular Coder

 
Join Date: Jul 2006
Posts: 399
Thanks: 33
Thanked 7 Times in 7 Posts
sybil6 can only hope to improve
the xhr class is simple and does reference the ie methods:
Code:
  function xhr(){
var xmlHttp=null;
try{xmlHttp=new XMLHttpRequest();}
catch (e){
try{xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
catch (e){xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}
i try setTimeout('getajax',100), but still nothing on ie,
yep it works on safari and ff
sybil6 is offline   Reply With Quote
Old 03-29-2009, 04:35 PM   PM User | #4
bdl
Regular Coder

 
Join Date: Apr 2007
Location: Camarillo, CA US
Posts: 590
Thanks: 4
Thanked 83 Times in 82 Posts
bdl is an unknown quantity at this point
A couple more thoughts..

What version of IE?

I'm wondering if it has to do with your selector:
Quote:
Code:
var div=document.getElementById("thediv").style.backgroundColor=p.responseText;
Throw a couple of alert()'s in there and verify that IE actually is using an XHR call and returning text to the page. If so, it might simply be your CSS selector.

Also, I note that your syntax is missing some semicolons, IE's scripting engine can be a buggaboo about things like that.
bdl is offline   Reply With Quote
Old 03-29-2009, 04:58 PM   PM User | #5
sybil6
Regular Coder

 
Join Date: Jul 2006
Posts: 399
Thanks: 33
Thanked 7 Times in 7 Posts
sybil6 can only hope to improve
ok thanks, i'll keep on debugging
sybil6 is offline   Reply With Quote
Old 03-29-2009, 11:37 PM   PM User | #6
sybil6
Regular Coder

 
Join Date: Jul 2006
Posts: 399
Thanks: 33
Thanked 7 Times in 7 Posts
sybil6 can only hope to improve
I finally find out , ie was caching the timeout i added this:
Code:
p.setRequestHeader('If-Modified-Since','Wed, 05 Apr 2006 00:00:00 GMT');
and the setTimeout function worked.
sybil6 is offline   Reply With Quote
Old 03-30-2009, 12:09 AM   PM User | #7
bdl
Regular Coder

 
Join Date: Apr 2007
Location: Camarillo, CA US
Posts: 590
Thanks: 4
Thanked 83 Times in 82 Posts
bdl is an unknown quantity at this point
Ah, the old IE caching problem. I know it well.
bdl is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:18 AM.


Advertisement
Log in to turn off these ads.