Hi,
I have recently been going through ajax tutorials and i came up with the following codes..I am getting my readystate to be 0 which means it is nt initialised.Why don't I get a code of 4 and what doesn the code 0 really mean? How can I solve this problem ?
Thanks in adv
I have recently been going through ajax tutorials and i came up with the following codes..I am getting my readystate to be 0 which means it is nt initialised.Why don't I get a code of 4 and what doesn the code 0 really mean? How can I solve this problem ?
Code:
<html>
<head>
<script type="text/javascript">
function tr(){
if (window.XMLHttpRequest) // Object of the current windows
{
xhr = new XMLHttpRequest(); alert("firefox"); // Firefox, Safari, ...
}
else
if (window.ActiveXObject) // ActiveX version
{
xhr = new ActiveXObject("Microsoft.XMLHTTP");alert("IE"); // Internet Explorer
} alert(xhr.readyState);
xhr.onreadystatechange =function chk(){
if (xhr.readyState == 4)
{
alert("I am ready");
} else
{
alert("I am not ready");
}
}
}
</script>
</head>
<body>
<button onclick="tr()">tryme</button>
</body>
</html>
Thanks in adv
Comment