Jump to content

Ajax Issue : Not working in IE8, but works on FF & Chrome


elabuwa

Recommended Posts

Hi guys,

 

below is the piece of code, I'm using for some simple ajax stuff.

However, IE8 gives a warning and the script does not work, but it works in chrome & FF.

Any help is greatly appreciated coz i'm bamboozled with this.

 


http = getHTTPObject();

function getHTTPObject(){
  var xmlhttp;

  /*@cc_on

  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    }catch(e){
      try{
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }catch(E){
      xmlhttp = false;
    }
  }
  @else
    xmlhttp = false;
  @end @*/

  if(!xmlhttp && typeof XMLHttpRequest != 'undefined'){
    try {
      xmlhttp = new XMLHttpRequest();
    }catch(e){
      xmlhttp = false;
    }
  }

  return xmlhttp;
}


function show_media_type(pub_type){
var url = "get_media.php?media_type=" + pub_type;
http.open("GET", url, true);
http.onreadystatechange = showmedia;
http.send(null);
}
function confirm_media(){
  if(http.readyState == 4){
    [b]document.getElementById('header').innerHTML = http.responseText;[/b]
  }
}
function showmedia(){
  if(http.readyState == 4){
    [b]document.getElementById('publications').innerHTML = http.responseText;[/b]
  }
}
function test(pid){
if(pid.length==0){
	pid = "test";
}
alert(pid);
}
function selected_media(pid){
var url = "confirm_media.php?media_id=" + pid;
http.open("GET", url, true);
http.onreadystatechange = confirm_media;
http.send(null);
}

 

IE8 error displaying this highlights the bolded lines above as to have issues and script stops working.

 

To see the entire thingi in action, please check dpmentor.com/gary

use "test" as username and password and click on "Publications" button.

If you use IE8, the error section on the bottom left will comeup and when clicked on will show the error.

 

I really appreciate any help.

 

Regards,

Elabuwa

thanks for the help. i got it sorted.

 

In case any one faces an issue likes this, it was the "id" names.

Apparently IE thinks in some wierd way id takes the name and id in some elements as the same. look for text "publications" in the code and you will see what I mean.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.