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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Text</title>
</head>
<body>
<script type="text/javascript">
function InitHTTPReq()
{
HTTPreq = false;
if(window.XMLHttpRequest)
{
try { HTTPreq = new XMLHttpRequest(); }
catch(e) { HTTPreq = false; }
}
else if(window.ActiveXObject)
{
try { HTTPreq = new ActiveXObject("Msxml2.XMLHTTP"); }
catch(e)
{
try { HTTPreq = new ActiveXObject("Microsoft.XMLHTTP"); }
catch(E) { HTTPreq = false; }
}
}
if(HTTPreq)
{
/* La on defini quel est la fonction qui ecoute les changement d'état de la requete */
HTTPreq.onreadystatechange = ReadyStateChange;
window.alert('objet XMLReq créé, envois de la requete.');
HTTPreq.open("GET", 'http://www.alloshare.com/data.xml', true);
HTTPreq.send(null);
return true;
}
return false;
}
function ReadyStateChange()
{
if (HTTPreq.readyState == 4)
{
window.alert('Les infos sont chargées');
if(HTTPreq.responseXML == null)
window.alert('Erreur : les infos recu ne sont pas du xml');
else
window.alert('les infos recu sont du xml');
document.getElementById("txt").value=HTTPreq.responseText;
}
}
</script>
<input name="aa" type="button" value="Afficher" onclick="InitHTTPReq()"/>
<input name="txt" type="text" value="" size="80" />
</body>
</html> |
Partager