onreadystatechange do nothing
i wrote-
function updateEventItems(value)
{ var xmlObj=null;
if (window.XMLHttpRequest)
xmlObj=new XMLHttpRequest();
else if (window.ActiveXObject)
xmlObj=new ActiveXObject("Microsoft.XMLHTTP");
else return;
xmlObj.onreadystatechange=function()
{ if(xmlObj.readyState==4) alert("ok");
}
}
and in some component i have added-
onchange="updateEventItems(this.value)"
i guess im missing something because im not getting the "ok" alert
what is wrong ?
thanks in advanced.
Re: onreadystatechange do nothing
Because you are saying when the file is ready then do whatever is inside that function. If you are not sending anything to the file, then you wont get the alert box. Create an empty file, and then add the following lines to the end:
Code:
xmlObj.open ("POST", "./file.ext", true);
xmlObj.setRequestHeader ("Content-Type", "application/x-www-form-urlencoded");
xmlObj.send (null);
then you should get the alert box, because javascript went to the page, did something (in this case just returned an empty file), and it came back successfully, so you should get the alert box.
And one other thing, your xmlObj should be this:
Code:
var xmlObj = (window.ActiveXObject) ? new ActiveXObject ("Microsoft.XMLHttp") : new XMLHttpRequest();