diff --git a/robocze/script.js b/robocze/script.js index 5aa4aa9..5af104a 100644 --- a/robocze/script.js +++ b/robocze/script.js @@ -26,22 +26,35 @@ function init() { } function initAjax() { - try { - if (window.XMLHttpRequest) { - ajax = new XMLHttpRequest(); - ajax.overrideMimeType('text/xml'); - } - else if (window.ActiveXObject) - ajax = new ActiveXObject('Microsoft.XMLHTTP'); - else throw 'AJAX Error'; - } - catch (e) { - return false; + try + { + ajax = new XMLHttpRequest(); // nowoczesne przegladarki + ajax.overrideMimeType('text/xml'); } - if (!ajax) { - alert('AJAX Error'); - return false; + catch(e) // IE <= 6 + { + var XmlHttpVersions = [ + 'MSXML2.XMLHTTP.6.0', + 'MSXML2.XMLHTTP.5.0', + 'MSXML2.XMLHTTP.4.0', + 'MSXML2.XMLHTTP.3.0', + 'MSXML2.XMLHTTP', + 'Microsoft.XMLHTTP' + ]; + for (var i=0; i < XmlHttpVersions.length && null === ajax; i++) + { + try + { + ajax = new ActiveXObject(XmlHttpVersions[i]); + } catch (e) {} + } + + if (null === ajax) + { + throw new Error('AJAX Error'); + } } + return true; }