XMLHttpRequst return null on Chrome
Posted
by BoltBait
on Stack Overflow
See other posts from Stack Overflow
or by BoltBait
Published on 2010-04-10T18:10:00Z
Indexed on
2010/04/10
18:13 UTC
Read the original article
Hit count: 269
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.
© Stack Overflow or respective owner