Jonas Raoni ha scritto:
Randy Webb escreveu:
kd****@gmail.com said the following on 11/20/2006 8:49 PM:
[...]
And if you are running it locally the readyState will never be 200.
Also checking for the constant "200" isn't nice in my opinion, because
what defines the status is just the first digit of the code, the others
act as a kind of sub-status.
--
Jonas Raoni Soares Silva
http://www.jsfromhell.com
Thanks a lot buddies.
It's quite clear to me.
But I also found this Ajax library
and to check the status it's use
a boolean var.
function XHConn()
{
var xmlhttp, bComplete = false;
try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
catch (e) { try { xmlhttp = new XMLHttpRequest(); }
catch (e) { xmlhttp = false; }}}
if (!xmlhttp) return null;
this.connect = function(sURL, sMethod, sVars, fnDone)
{
if (!xmlhttp) return false;
bComplete = false;
sMethod = sMethod.toUpperCase();
try {
if (sMethod == "GET")
{
xmlhttp.open(sMethod, sURL+"?"+sVars, true);
sVars = "";
}
else
{
xmlhttp.open(sMethod, sURL, true);
xmlhttp.setRequestHeader("Method", "POST "+sURL+" HTTP/1.1");
xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
}
xmlhttp.onreadystatechange = function(){
//HERE -------------!bComplete-------------
if (xmlhttp.readyState == 4 && !bComplete)
{
bComplete = true;
fnDone(xmlhttp);
}};
xmlhttp.send(sVars);
}
catch(z) { return false; }
return true;
};
return this;
}
var myConn = new XHConn();
if (!myConn) alert("XMLHTTP not available. Try a newer/better
browser.");
var fnWhenDone = function (pXML) { alert(pXML.responseText); };
myConn.connect("test.txt", "GET","",fnWhenDone);
Is it the same case or not ?
Bye.