Hallo,
Du kannst Daten holen, aber nicht schreiben. Zum Schreiben brauchst du eine serverseitige Scriptsprache.
Holen, siehe ein älteres Beispiel von mir
(als .htm zusammen mit einer data.txt mit etwas Inhalt, sowie einer prototype-1.6.0.js nach 'C:/mein_verzeichnis' packen):
<?xml version="1.0" encoding="UTF-8" ?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Daten aus einer Text-Datei holen</title>
<script type="text/javascript"
src="File:///C:/mein_verzeichnis/prototype-1.6.0.js"></script>
<!-- ohne 'File:///' funktioniert es nicht! -->
</head>
<body>
<script type="text/javascript">
~~~~~~javascript
/* <![CDATA[ */
window.onload = init;
function init() {
/* entnommen von: http://www.prototypejs.org/learn/introduction-to-ajax */
new Ajax.Request('data.txt', {
method :'get',
onSuccess : function(transport) {
var response = transport.responseText || "no response text";
alert("Success! \n\n" + response);
},
onFailure : function() {
alert('Something went wrong...')
}
});
}
/* ]]> */
~~~~~~html
</script>
</body>
</html>
Gruß, Nils
--
Bookmarks
Bookmarks