> In the mean time, if anyone can point out why passing
the span id to the
> stateChanged function causes the xmlHttp.readyState to
always stay at 0,
> that
> would be very useful!
You can't pass an argument to a callback function like that.
You can create
your own callback function and set it up inside a calling
function so that
the argument is not lost:
var xmlHttp
function processRemote(callback, str) {
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null) {
alert ('Browser does not support HTTP Request');
return;
}
var url='/includes/ajax/ajax_validate.asp';
url=url+"?val="+str;
url=url+"&sid="+Math.random();
xmlHttp.open("GET",url,true);
xmlHttp.onreadystatechange=function() {
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
var temp = new Array();
temp.push(xmlHttp.responseText);
callback.apply(callback,temp);
}
}
xmlHttp.send(null);
}
function GetXmlHttpObject() {
var objXMLHttp=null;
if (window.XMLHttpRequest) {
objXMLHttp=new XMLHttpRequest();
}
else if (window.ActiveXObject) {
objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
return objXMLHttp;
}
function checkElement(str, spanid) {
if (str.length==0) {
document.getElementById(spanid).innerHTML="";
return;
}
var callback = function(str) {
document.getElementById(spanid).innerHTML=str;
}
var result = processRemote(callback, str);
}
That should work.
--
--
Tom Muck
co-author Dreamweaver MX 2004: The Complete Reference
http://www.tom-muck.com/
Cartweaver Development Team
http://www.cartweaver.com
Extending Knowledge Daily
http://www.communitymx.com/