Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Need some help with AJAX in IE
Old 08-26-2008, 03:45 PM Need some help with AJAX in IE
Novice Talker

Posts: 7
Trades: 0
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);
}
Raphy is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-26-2008, 06:29 PM Re: Need some help with AJAX in IE
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
you are missing a call to create the later MS XMLHTTP Object creation


=new ActiveXObject("Msxml2.XMLHTTP");

You are better off using the try ... catch exception handling for the object creation it's a little more reliable across browsers

Code:
		try {
		  m_oXML=new XMLHttpRequest();
		  } catch (e) {
		  try {
			m_oXML=new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
			try {
			  m_oXML=new ActiveXObject("Microsoft.XMLHTTP");
			  } catch (e) {
			  alert("Use the alternative HTML interface please");
			  return false;
			  }
			}
		  }
	m_oXML.onreadystatechange=function() {
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to Need some help with AJAX in IE
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.49819 seconds with 12 queries