CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2008
    Posts
    4

    Working in FireFox not IE

    Hi i have an Ajax script which is working in FireFox but not IE, obviosuly i want a wide range of people to be able to view, but cant seem to figure it out. Any help would be great, here is the code:

    Code:
    	 function LocationClick(e){
    	  	 if(e.elementID != null){
    			shape = map.GetShapeByID(e.elementID);
    			country = shape.GetID()
    			if(country == "msftve_1001_200000")
    				country = "AUSTRALIA";
                                     ..........
                                     else if (country == "msftve_1001_200017")
    				country = "BRAZIL";
    			getCountry();
    			}
    	  	}
    
    
                                    function getCountry() {
    		xhr = new XMLHttpRequest();
    		submission = "id="+ country;
    		   xhr.open("GET", "tickets.php?" + submission);
    		   xhr.onreadystatechange = processNameData;
    		   xhr.send(null);
    	    }
    
    
    		function processNameData() {
    		if (xhr.readyState == 4) {
    			var data = xhr.responseText;
    			document.getElementById("ajaxTickets").innerHTML = xhr.responseText;
    			}
    		else {
    			document.getElementById("ajaxTickets").innerHTML = '<img src="images/loading.gif">';
    			}
    	 	}
    Now in IE the loading picture works, but the information is never loaded. Any help would be great
    thanks
    al
    Last edited by PeejAvery; May 5th, 2008 at 10:04 AM. Reason: Fixed code tags.

  2. #2
    Join Date
    May 2002
    Posts
    10,943

    Re: Working in FireFox not IE

    XMLHttpRequest() is for Safari and Firefox (and other browsers). For IE you need either Msxml2.XMLHTTP or Microsoft.XMLHTTP. The following try...catch will work for all modern browsers.

    Code:
    var xhr;
    try {xhr = new XMLHttpRequest();}
    catch(e) {
      try {xhr = new ActiveXObject("Msxml2.XMLHTTP");}
      catch(e) {
        try {xhr = new ActiveXObject("Microsoft.XMLHTTP");}
        catch(e) {
          alert("Your browser does not support AJAX!");
          return false;
        }
      }
    }
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  3. #3
    Join Date
    Apr 2008
    Posts
    4

    Re: Working in FireFox not IE

    thanks, worked a treat!

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured