| 12
 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
 
 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
	<title>exemple 1</title>
</head>
<body>
 
<script type="text/javascript" src="/home/Ajax/ajax1.js"></script>
 
<p>
<a href="javascript:ajax();">Cliquez-moi !</a>
</p>
 
</body>
</html>
 
et voici le code java associé
 
unction ajax()
{
    var xhr=null;
 
    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }
    //on appelle le fichier reponse.txt
    xhr.open("GET", "http://home/Ajax/reponse.txt", false);
    xhr.send(null);
 
    alert(xhr.responseText); | 
Partager