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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.