Во всех браузерах, кроме opera не срабатывает условие if (req.readyState == 4 && req.status == 200)В чем проблема, подскажите. Сам код полностю рабочий. Выполняется именно так, как и должен, но только в опере | Код | <script type="text/javascript"> function ge(e) {return document.getElementById(e);} function show(id) {ge(id).style.display = '';} function hide(id) {ge(id).style.display = 'none';}
var req;
if (window.XMLHttpRequest) {req = new XMLHttpRequest();} else if (window.ActiveXObject) { try {req = new ActiveXObject('Msxml2.XMLHTTP');} catch (e){} try {req = new ActiveXObject('Microsoft.XMLHTTP');} catch (e){} }
function reqOpen(_url, _data, _callback) { _data = _data || null; _callback = _callback || null; req.onreadystatechange = function () { if (req.readyState == 4 && req.status == 200) { if (_callback) { _callback(req.responseText); } } }
if (_url.indexOf('?') == -1) { _url += '?'+Math.random(); } else { _url += '&'+Math.random(); }
req.open('POST', _url, true); req.setRequestHeader('X-REQUESTED-WITH', '1'); req.send(_data); }
function addServer () { var sbutton = document.getElementById('sbutton'); sbutton.onclick = null; sbutton.disabled = true;
reqOpen('/edit?op=serverBox', null, function (html) { sbutton.value = 'Сохранить'; sbutton.onclick = 'document.forms["server"].submit();'; var dv = document.createElement('DIV'); dv.innerHTML = html; ge('serversList').appendChild(dv); }); }
function selectServer(v, tId) { var sbutton = document.getElementById('sbutton');
if (v == -1) { sbutton.disabled = false; show('srvName_'+tId); show('fieldTable_'+tId); } else if (v != 0) { sbutton.disabled = false; show('fieldTable_'+tId); hide('srvName_'+tId); } else { sbutton.disabled = true; hide('srvName_'+tId); hide('fieldTable_'+tId); } } </script>
|
Это сообщение отредактировал(а) ImamMahdi - 15.2.2009, 05:12
|