Jump to content

IE / FireFox responseText


astralaaron

Recommended Posts

The problem I am having is only in IE (only tested in version 6)I am making an AJAX call with this code:

 function getHttp(){    if(window.XMLHttpRequest){      return new XMLHttpRequest();    } else if(window.ActiveXObject){      return new ActiveXObject("Microsoft.XMLHTTP");      } else {       alert('your browser is not compatable');      }  }  var http2 = getHttp();    function checkit(){     if(http2.readyState == 0 || http2.readyState == 4){      http2.open("GET","checkurl.php",true);      http2.onreadystatechange = vresult;      http2.send(null);     }    }    function vresult(){      if(http2.readyState == 4){	alert(http2.responseText);        }      }

on the checkurl.php it either echo's out a URL if it is in the database, or it echo's the letter xon Firefox it the vresult() function alert pops up with the right textm either x or the URL BUT in IEthe alert is always 0 responseText always comes back as zero for some reason in IE.... please help!

Link to comment
Share on other sites

I found a solution looking around on the internet, I don't know why it fixes the problem but it does. function checkit(){ checkurl = "urlCheck.php?randval="+Math.random(); if(http2.readyState == 0 || http2.readyState == 4){ http2.open("GET",checkurl,true); http2.onreadystatechange = vresult; http2.send(null); } }adding a random variable on the end of the URL all of a sudden makes the responseText see whats on the page in IE.. without it the responseText is always 0if anyone can explain that would be nice! but it works anyway so I am fine :)

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...