Goodjee: Ajax InternetExplorer muckt

Beitrag lesen

Folgender Code funktioniert leider nur mit Firefox, sobald man ein neben dem script liegendes xmlfile öffnen will blockirt der ie.

<script type="text/javascript">
 var selectv=0;
 var page=1;
 function ajaxObject(url)
 {
  var xmlHttp;
  try
   {
    xmlHttp=new XMLHttpRequest();
   }
  catch (e)
  {
   // Internet Explorer
   try
   {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
   }
   catch (e)
   {
    try
    {
     xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    catch (e)
    {
     alert("Your browser does not support AJAX!");
     return false;
    }
   }
  }
  xmlHttp.onreadystatechange=function update()
  {
   if(xmlHttp.readyState==4)
   {
    var xml=xmlHttp.responseXML.documentElement;
    switch(xml.getElementsByTagName("type")[0].childNodes[0].nodeValue)
    {
     case "vote":
      loadQuestion(xml);
      break;
     case "content":
      loadContent(xml);
      break;
     default:
                       alert(xml.getElementsByTagName("type")[0].childNodes[0].nodeValue);
                       break;
    }
   }
  }
  xmlHttp.open("GET",url,true);
  xmlHttp.send(null);
 }