Search the Community
Showing results for tags 'test'.
-
Hi, I can not figure out why the first example does not work. Also, I downloaded and tested code from this site - and it does not work... This example starts on page 433: Here is my ajax.js: function getXMLHttpRequestObject() { var ajax = null; if (window.XMLHttpRequest) { ajax = new XMLHttpRequest(); } else if (window.ActiveXObject) { ajax = new ActiveXObject('MSXML2.XMLHTTP.3.0'); } return ajax; } Here is my test.js: window.onload = function() { 'use strict'; var ajax = getXMLHttpRequestObject(); ajax.onreadystatechange = function() { if (ajax.readyState == 4) { if ((ajax.status >= 200 && ajax.status < 300) || (ajax.status == 304)) { document.getElementById('output').innerHTML = ajax.responseText; } else { document.getElementById('output').innerHTML = 'Error: + ajax.statusText; } } }; document.getElementById('btn').onclick = function() { ajax.open('GET', 'resources/test.txt', true); ajax.send(null); }; }; Also, there is some text file in resources/test.txt... And it does not work (tested on Firefox, Opera, IE, Chrome). The same is with code downloaded form this site - when I click on button - nothing happens. Do you know what could be the problem? Thanks in advance!