1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| <html>
<head>
<style type="text/css">
body { background-color:#C0C0C0;}
</style>
<script type="text/javascript">
function load_it() {
var XMLHTTP = XMLHttpRequest;
if(typeof XMLHTTP != "undefined") {
var req = new XMLHTTP;
req.onreadystatechange = function() {
if(req.readyState == 4) {
alert('ici');
var rep = req.responseText;
alert(rep);
document.getElementById("display_reponse").innerHTML = rep;
}
}
req.open("GET", "http://127.0.0.1/test.txt", true);
req.send(null);
} else { alert("your browser doesn't support ajax"); }
}
</script>
</head>
<body>
<div>
<input type="button" name="mon_clic" value="clic" onclick="load_it();" />
</div>
<div id="display_reponse">test</div>
</body>
</html> |
Partager