Security error ajax
narama87
Messages postés
113
Statut
Membre
-
avion-f16 Messages postés 20368 Date d'inscription Statut Contributeur Dernière intervention -
avion-f16 Messages postés 20368 Date d'inscription Statut Contributeur Dernière intervention -
Bonjour,
voilà , j'ai un script ajax , qui en l'exécutant voici qu'on m'affiche :
Security Error: Content at file:///home/aheadit/Desktop/ajax.html may not load data from file:///home/aheadit/Desktop/text1.txt.
voici le script :
<html>
<head>
<script type="text/javascript">
function loadXMLDoc(url)
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET",url,false);
xmlhttp.send(null);
document.getElementById('test').innerHTML=xmlhttp.responseText;
}
</script>
</head>
<body>
<div id="test">
<h2>Click to let AJAX change this text</h2>
</div>
<button type="button" onclick="loadXMLDoc('text1.txt')">Click Me</button>
<button type="button" onclick="loadXMLDoc('text2.txt')">Click Me</button>
</body>
</html>
une idée ?
voilà , j'ai un script ajax , qui en l'exécutant voici qu'on m'affiche :
Security Error: Content at file:///home/aheadit/Desktop/ajax.html may not load data from file:///home/aheadit/Desktop/text1.txt.
voici le script :
<html>
<head>
<script type="text/javascript">
function loadXMLDoc(url)
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET",url,false);
xmlhttp.send(null);
document.getElementById('test').innerHTML=xmlhttp.responseText;
}
</script>
</head>
<body>
<div id="test">
<h2>Click to let AJAX change this text</h2>
</div>
<button type="button" onclick="loadXMLDoc('text1.txt')">Click Me</button>
<button type="button" onclick="loadXMLDoc('text2.txt')">Click Me</button>
</body>
</html>
une idée ?
A voir également:
- Security error ajax
- Microsoft security essentials - Télécharger - Antivirus & Antimalwares
- Network error ✓ - Forum Réseaux sociaux
- Fan error lenovo ✓ - Forum Refroidissement
- Eespt technical error ✓ - Forum TNT / Satellite / Réception
- Antivirus gratuit norton internet security - Télécharger - Antivirus & Antimalwares
1 réponse
Tu dois faire comme ça pour savoir quand la requête est terminée :
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && (xmlhttp.status == 200 || xmlhttp.status == 0)) {
document.getElementById('test').innerHTML=xmlhttp.responseText;
}
};https://openclassrooms.com/fr/courses/245710-ajax-et-lechange-de-donnees-en-javascript/244798-lobjet-xmlhttprequest