SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: XMLHttpRequest

Hybrid View

  1. #1
    SitePoint Addict
    Join Date
    May 2005
    Location
    London, ON
    Posts
    360
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question XMLHttpRequest

    Hello,

    I have an Ajax script I am using that works perfect in firefox, but the request isn't working in IE. I thought I had it set up to handle the browser differences...

    What am I doing wrong?

    Code:
    <script type="text/javascript">
    function showPreview(spnsr, pgm, cmp) {
    	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) {
    			document.getElementById("announcementPreview").innerHTML=xmlHttp.responseText;
    		}
    		if(xmlHttp.readyState==1 || xmlHttp.readyState==2 || xmlHttp.readyState==3) {
    			var loadingImg = '<img src="images/loadingAnimation.gif" alt="Loading.." style="margin:auto;">';
    			document.getElementById("announcementPreview").innerHTML=loadingImg;
    		}
    	}
    
    	var appendString = "?spnsr="+spnsr+"&pgm="+pgm+"&cmp="+cmp;
    	xmlHttp.open("GET","showAnnouncement.php" + appendString,true);
    	xmlHttp.send();
    
    }
      
    </script>
    Ryan Price
    Subscribe to my blog for regular tips and tricks

  2. #2
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What JavaScript error do you get?

  3. #3
    SitePoint Addict
    Join Date
    May 2005
    Location
    London, ON
    Posts
    360
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    From what I can see, I'm not getting an error at all. I'd post the link to let you have a look, but its run on my local machine instead of on a server...

    If only there was something like firebug for IE I could probably hunt this down. Any other suggestions?
    Ryan Price
    Subscribe to my blog for regular tips and tricks

  4. #4
    code ninja hamstu's Avatar
    Join Date
    Nov 2002
    Location
    Montréal, Canada
    Posts
    375
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Jeanco View Post
    If only there was something like firebug for IE I could probably hunt this down. Any other suggestions?
    The IE Developer Toolbar might be useful, or maybe Firebug Lite.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •