Created
June 28, 2010 13:47
-
-
Save anonymous/455857 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getXMLHttpRequest() { | |
var xhr = null; | |
if (window.XMLHttpRequest || window.ActiveXObject) { | |
if (window.ActiveXObject) { | |
try { | |
xhr = new ActiveXObject("Msxml2.XMLHTTP"); | |
} catch(e) { | |
xhr = new ActiveXObject("Microsoft.XMLHTTP"); | |
} | |
} else { | |
xhr = new XMLHttpRequest(); | |
} | |
} else { | |
alert("Votre navigateur ne supporte pas l'objet XMLHTTPRequest..."); | |
return null; | |
} | |
return xhr; | |
} | |
function loadContents(page, id){ | |
xhr = getXMLHttpRequest(); | |
xhr.onreadystatechange = function() { | |
if (xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0)) { | |
document.getElementById(id).innerHTML = ''; | |
document.getElementById(id).innerHTML = xhr.responseText; | |
} | |
}; | |
xhr.open("GET", page, true); | |
xhr.setRequestHeader('Content-type','application/x-www-form-urlencoded'); | |
xhr.send(null); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment