XMLHttpRequst return null on Chrome
- by BoltBait
I have the following code that works fine in IE:
<HTML>
<BODY>
<script language="JavaScript">
text="";
req = new XMLHttpRequest();
if (req)
{
req.onreadystatechange = processStateChange;
req.open("GET", "http://www.boltbait.com", true);
req.send();
}
function processStateChange()
{
// is the data ready for use?
if (req.readyState == 4) {
// process my data
alert(req.status);
alert(req.responseText);
}
}
</script>
</BODY>
</HTML>
In IE, the first alert returns 200, the second returns the web page.
However, in Chrome the first alert returns 0 and the second returns the empty string.
My intent is to grab a web page into a string for processing. If I'm not doing this right, how should I be doing this?
Thanks.