SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast iwiz_seo's Avatar
    Join Date
    Sep 2009
    Posts
    46
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Ajax not working in Internet Explorer!!!

    Hi all,

    The following Ajax script is working in all the browser expect Internet explorer.

    Code:
    var xmlHttp;
    
    function GetXmlHttpObject(){
    	var xmlHttp;  // The variable that makes Ajax possible!
    	
    	try{
    		// Opera 8.0+, Firefox, Safari
    		xmlHttp = new XMLHttpRequest();
    	} catch (e){
    		// Internet Explorer Browsers
    		try{
    			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    		} catch (e) {
    			try{
    				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    			} catch (e){
    				// Something went wrong
    				alert("Your browser broke!");
    				return false;
    			}
    		}
    	}
    	
    	return xmlHttp;
    }
    
    
    
    
    ///Supplier Master
    function Getsuppliercode(){
    
    	var SupplierGroup = document.getElementById('supplier_group').value;
    	
    	if(SupplierGroup == ''){
    		document.getElementById('suppliercode').value = '';
    		document.getElementById('suppliercode').innerHTML ='<option value="">--- SELECT ---</option>';
    	}
    	else{
    		
    		xmlHttp=GetXmlHttpObject()
    		var queryString = "?supplier_group="+SupplierGroup;
    		//alert (queryString);
    		xmlHttp.onreadystatechange=function()
    		{ 
    				if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
    				var dep = ''; 
    				var result = xmlHttp.responseText;
    				//document.getElementById('suppliercode').value = '';
    				document.getElementById('suppliercode').innerHTML ='<option value="">--- SELECT ---</option>';
    				//document.getElementById('empname').value = '';
    				var re = result.split(',');
    				for(i=0;1<re.length;i++){
    					if(re[i] == ''){
    						break;
    				}
    				//alert("<option value="+re[i]+">"+re[i]+"</option>")
    				document.getElementById('suppliercode').innerHTML += "<option value="+re[i]+">"+re[i]+"</option>";	
    				}									
    			} 
    		}
    		//alert ("getsuppliercode.php" +queryString);
    		xmlHttp.open("GET","getsuppliercode.php" + queryString,true);
    		xmlHttp.send(null);
    		
    		return true;
    	}		
    }
    Could somebody tell me why it is not working in IE.

    Thank you.

  2. #2
    Non-Member thewebhostingdir's Avatar
    Join Date
    Oct 2005
    Posts
    703
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is there any error message are you receiving while accessing your script in IE? and also provide us the IE version which you are using?

  3. #3
    SitePoint Enthusiast iwiz_seo's Avatar
    Join Date
    Sep 2009
    Posts
    46
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No I am not getting error message, while i am accessing the page using IE the combo box not showing the result instead it shows an empty combo box but i am getting result while accessing with firefox. I am using IE7.

    Thank you for you help.

  4. #4
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do some more debugging. Check the value of responseText for example. Check the values of your other variables.

    One thing I'll throw out at you, is that IE is more aggressive caching ajax requests than some browsers. Make sure your web server is sending appropriate http headers along with the response, to indicate to the browser not to cache the response. This is the prefered way. The ugly way is to append an ever changing value to the query string for each request, like the time in miliseconds. Well, assuming you don't want it cached.

    In any case, clear your cache. The browser might have retained a previous version from while you were developing.


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
  •