I'll make it short. Here's the code (the GET request is taken from a Google example):
The problem: the alert never displays. Firebug shows xmlhttp.status = 0 and responseText = "" all the time. The page is on my local machine.Code:<html> <script> function hello() { var xmlhttp = null; if (window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest(); if (typeof xmlhttp.overrideMimeType != 'undefined') { xmlhttp.overrideMimeType('text/xml'); } } else { if (window.ActiveXObject) { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } else { alert('Perhaps your browser does not support xmlhttprequests?'); } } xmlhttp.open("GET", "http://www.google.com/search?hl=en&q=benjamin+schirmer", true); xmlhttp.send(); xmlhttp.onreadystatechange = function(){ if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { alert("OK"); } else { } }; } </script> <body onload="hello()"> </body> </html>
Any ideas on how to get this to work? Thanks!
P.S> I've tried doing a synchronous call as well but that gives me an error message; something like 0x80004005 (NS_ERROR_FAILURE) [nsIXMLHttpRequest.send


Reply With Quote

Bookmarks