Results 1 to 2 of 2

Thread: AjAx problem in IE????

  1. #1
    Join Date
    Jul 2008
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default AjAx problem in IE????

    Hi frnds...

    I am doing poll in AJAX..this is first time i am using AJAX.. The below code is working fine in mozilla, chrome...but not working in IE....plz check the below code...and change the code as correctly..i think problem in object creation in IE..

    Code:
    <script>
     //VOTE POLL -------------------------------------
        function makeVote(url, parameters) {
          http_request = false;
          if (window.XMLHttpRequest) { // Mozilla, Safari,...
             http_request = new XMLHttpRequest();
             if (http_request.overrideMimeType) {
             	// set type accordingly to anticipated content type
                //http_request.overrideMimeType('text/xml');
                http_request.overrideMimeType('text/html');
             }
          } else if (window.ActiveXObject) { // IE
             try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
             } catch (e) {
                try {
                   http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
             }
          }
          if (!http_request) {
             alert('Cannot create XMLHTTP instance');
             return false;
          }
          
          http_request.onreadystatechange = alertVote;
          http_request.open('POST', url, true);
          http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
          http_request.setRequestHeader("Content-length", parameters.length);
          http_request.setRequestHeader("Connection", "close");
          http_request.send(parameters);
       }
    
       function alertVote() {
          if (http_request.readyState == 4) {
             if (http_request.status == 200) {
                //alert(http_request.responseText);
                result = http_request.responseText;
                document.getElementById('vote_msg').innerHTML = result;            
             } else {
                alert('There was a problem with the request.');
             }
          }
       }
       
    function getCheckedValue(radioObj) {
    	if(!radioObj)
    		return "";
    	var radioLength = radioObj.length;
    	if(radioLength == undefined)
    		if(radioObj.checked)
    			return radioObj.value;
    		else
    			return "";
    	for(var i = 0; i < radioLength; i++) {
    		if(radioObj[i].checked) {
    			return radioObj[i].value;
    		}
    	}
    	return "";
    }
     
       function submit_vote(obj) {
    	  var vote_value = getCheckedValue(document.forms['vote-form'].elements['opt']);
          var poststr = "poll_id=" + encodeURI( document.getElementById("poll_id").value ) +
                        "&voteid=" + encodeURI( vote_value);				
          makeVote('vote.php', poststr);
       }
    </script>
    
            
    <script type="text/javascript">
    
    	function getxmlhttp(){
    		var page_request = false;
    		if (window.XMLHttpRequest){
    			return xmlhttp = new XMLHttpRequest();
    		}else if (window.ActiveXObject){
    			try {
    				return xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    			}catch (e){
    				try{
    					return xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    				}catch (e){}
    			}
    		}else{
    			return false
    		}
    	}
    	
    	function getpage(url, container){
    		xmlhttp = getxmlhttp();
    		xmlhttp.open('GET', url);
    		xmlhttp.onreadystatechange = function(){
    			if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
    				document.getElementById(container).innerHTML = xmlhttp.responseText;
    			}else{
    			document.getElementById(container).innerHTML = "<h3><font color=#1B1B1B>Loading.....</font></h3>";
    				//document.getElementById(container).innerHTML = '<div style="text-align:center;"><img src="images/ajax-loader.gif" /></div>';
    			}			
    			//alert(xmlhttp.status);
    			//document.getElementById(container).innerHTML = xmlhttp.responseText;
    		}
    		xmlhttp.send(null);
    	}
    	
    	
    </script>
    i got error on page(Unknown Runtime Error on line 5)... ...at the bottom of the page status...the page not redirecting frm one page to another page...it displays LOADING..... thats it...Plz do this...

  2. #2
    Join Date
    Mar 2007
    Location
    New York, NY
    Posts
    557
    Thanks
    8
    Thanked 66 Times in 66 Posts

    Default

    Are you running it on a server or your computer? THe only known problem IE can have with Ajax that's different from other browsers is an access denied error.
    - Josh

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
  •