<html>
<head>
<title></title>
</head>
<body>
<script>
function getXmlHttp(){
var xmlhttp;
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
}
function func(xmlhttp)
{
alert('func start');
i=1;
while (xmlhttp.readyState != 4 && i < 100)
{
//alert('state '+xmlhttp.readyState+' i '+i);
i=i+1;
};
if(xmlhttp.readyState == 4)
{
alert('xmlhttp.readyState == 4!!!!!');
};
alert('func end');
};
function asd(url)
{
alert('START');
var xmlhttp = getXmlHttp();
xmlhttp.open('GET', url, true);
alert('Сделано: xmlhttp.open: '+url);
xmlhttp.onreadystatechange = func(xmlhttp);
xmlhttp.send(null);
alert('END!!');
};
</script>
<input onclick='asd("http://127.0.0.1/never4.0/test.html")' value='Отправить' type='button'>
</body>
</html>
Никак не получается xmlhttp.readyState = 4