[AJAX] Affichage avec Firefox
Voilà j'ai créé un tout petit bout de code afin de tester AJAX, le voici :
Code:
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
|
<%@PageLanguage="C#"AutoEventWireup="true"CodeFile="exo2.aspx.cs"Inherits="exo2" %>
<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
<title>Page sans titre</title>
<scriptlanguage="javascript"type="text/javascript">
function getXhr(){
if(window.XMLHttpRequest) // Firefox et autres
xhr = new XMLHttpRequest();
elseif(window.ActiveXObject){ // Internet Explorer
try {
xhr = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
}
else { // XMLHttpRequest non support‚ par le navigateur
alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
xhr = false;
}
}
function getData(dataSource,divID)
{
getXhr();
if(xhr)
{
var obj=document.getElementById(divID);
xhr.open("GET",dataSource);
xhr.onreadystatechange=function()
{
if(xhr.readystate==4 && xhr.status== 200)
{
obj.innerHTML=xhr.responseText;
}
}
xhr.send(null);
}
}
</script>
</head>
<body>
<formid="form1"runat="server">
<div>
<inputtype="button"value="Afficher"onclick="getData('http://localhost/ajax/data01.txt','targetDiv')"/>
</div>
<divid="targetDiv">
<p>Donn‚es : </p>
</div>
</form>
</body>
</html>
|
Sous IE le contenu de data01.txt s'affiche mais sous Firefox le contenu ne s'affiche pas et je n'ai pas de message d'arreur ?
Merci par avance de votre aide