Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,471
There are 627 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     Javascript :

Need some help with AJAX in IE

Thread title: Need some help with AJAX in IE
Closed Thread    
    Thread tools Search this thread Display Modes  
08-26-2008, 05:54 PM
#1
Raphy is offline Raphy
Raphy's Avatar
Status: Member
Join date: Aug 2008
Location: Boca Raton, FL
Expertise:
Software:
 
Posts: 146
iTrader: 4 / 100%
 

Raphy is on a distinguished road

Send a message via AIM to Raphy Send a message via MSN to Raphy Send a message via Skype™ to Raphy

  Old  Need some help with AJAX in IE

Hey guys, I'm trying to make a dynamic AJAX product updater that displays products based on the brand the user selects from a form drop menu. The following function works perfectly on Safari and Firefox, but on IE I get a 'Object Expected' error and I have NO idea on how to fix it. Does anyone here know how I could go about fixing this? The function I have is below.

Thanks for the help in advance.

Code:
function updateSkinCare() {
brandName = document.getElementById('searchTypeSkin').value;
emailValue = document.getElementById('clientEmail').innerHTML;
// AJAX CALL
var PageRequest = false;
if(window.XMLHttpRequest)pageRequest = new XMLHttpRequest();
else if(window.ActiveXObject) pageRequest = new ActiveXObject("Microsoft.XMLHTTP");
else return false;
pageRequest.onreadystatechange = function() {
if(pageRequest.readyState == 4 || pageRequest.readyState == "complete")  {
document.getElementById('skincarecontent').innerHTML = pageRequest.responseText;
  }
}
pageRequest.open('GET', "brandprodisplay.php?type=skincare&brand=" +brandName +"&email=" +emailValue, true);
pageRequest.send(null);
}

08-26-2008, 07:27 PM
#2
wezy is offline wezy
wezy's Avatar
Status: Junior Member
Join date: Jul 2008
Location: Belgium
Expertise:
Software:
 
Posts: 26
iTrader: 0 / 0%
 

wezy is on a distinguished road

Send a message via MSN to wezy Send a message via Skype™ to wezy

  Old

You can give this code a try, should work in all browsers.

Code:
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;
        	}
    	}
	}
	xmlHttp.onreadystatechange=function(){
      	if(xmlHttp.readyState==4){
      		var responce = xmlHttp.responseText;
		}
    };
    xmlHttp.open("GET","example.php",true);
    xmlHttp.send(null);
}
Hope it works,
Erwin

08-26-2008, 07:46 PM
#3
Raphy is offline Raphy
Raphy's Avatar
Status: Member
Join date: Aug 2008
Location: Boca Raton, FL
Expertise:
Software:
 
Posts: 146
iTrader: 4 / 100%
 

Raphy is on a distinguished road

Send a message via AIM to Raphy Send a message via MSN to Raphy Send a message via Skype™ to Raphy

  Old

As much as I wish I could tell you it worked - it didn't. =\

08-26-2008, 07:57 PM
#4
wezy is offline wezy
wezy's Avatar
Status: Junior Member
Join date: Jul 2008
Location: Belgium
Expertise:
Software:
 
Posts: 26
iTrader: 0 / 0%
 

wezy is on a distinguished road

Send a message via MSN to wezy Send a message via Skype™ to wezy

  Old

what kind of error do you get and on what line?

08-26-2008, 08:00 PM
#5
Raphy is offline Raphy
Raphy's Avatar
Status: Member
Join date: Aug 2008
Location: Boca Raton, FL
Expertise:
Software:
 
Posts: 146
iTrader: 4 / 100%
 

Raphy is on a distinguished road

Send a message via AIM to Raphy Send a message via MSN to Raphy Send a message via Skype™ to Raphy

  Old

Object expected error. It doesn't work at all, it's like the AJAX function isn't being called at all on IE, yet it works on the other browsers. I put an alert(); on the function to see if it was even being called on IE and the alert didn't pop up, so I'm trying to find another reason for why this is happening. Kind of weird to be honest, but whatever.

08-26-2008, 08:08 PM
#6
wezy is offline wezy
wezy's Avatar
Status: Junior Member
Join date: Jul 2008
Location: Belgium
Expertise:
Software:
 
Posts: 26
iTrader: 0 / 0%
 

wezy is on a distinguished road

Send a message via MSN to wezy Send a message via Skype™ to wezy

  Old

Very strange, because this the function I always use and it never let me down so far

08-26-2008, 08:10 PM
#7
Raphy is offline Raphy
Raphy's Avatar
Status: Member
Join date: Aug 2008
Location: Boca Raton, FL
Expertise:
Software:
 
Posts: 146
iTrader: 4 / 100%
 

Raphy is on a distinguished road

Send a message via AIM to Raphy Send a message via MSN to Raphy Send a message via Skype™ to Raphy

  Old

I have done so many more complicated stuff with the same function I use and it has worked before. I'm going to look at the stuff that I currently have setup to make sure that I'm doing everything correctly. IE needs to die though

Closed Thread    


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed