Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function GetData() {
- // 1. Istanziazione della richiesta (con versione IE 5-6)
- var xhr;
- if (window.XMLHttpRequest)
- xhr = new XMLHttpRequest();
- else if (window.ActiveXObject)
- xhr = new ActiveXObject("Msxml2.XMLHTTP");
- else
- throw new Error("Ajax non è supportato dal browser");
- // 2. Gestire la risposta del server
- xhr.onreadystatechange = function () {
- if (xhr.readyState < 4)
- document.getElementById('div1').innerHTML = "Loading...";
- else if (xhr.readyState === 4) {
- if (xhr.status == 200 && xhr.status < 300)
- document.getElementById('div1').innerHTML = xhr.responseText;
- }
- }
- // 3. Specificare metodo, URL e avviare le operaioni
- xhr.open('GET', 'data.html');
- xhr.send(null);
- }
- //alert("DEBUG: Script caricato correttamente");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement