Ucze sie AJAXa no i napisałem sobie skrypt, który powinien wypełniac plik, no ale nie działa - mógłby ktoś pomóc (wszytkie pliki sa w jednym folderze na sewerze www):
Plik zuo.html:
Kod
<html><body>
<script language="JavaScript" type="text/javascript">
function getXMLHTTPRequest() {
req = false;
try {
req = new XMLHttpRequest();
} catch(err1) {
try {
req = new ActiveXObject("Msxml2.XMLHTTP");
} catch (err2) {
try {
req = new ActiveXObject("Microsoft.XMLHTTP");
} catch (err3) {
req = false;
}
}
}
return req;
}
var http = getXMLHTTPRequest();
function useHttpResponse() {
var myurl = 'http://xxxx.eu/nauka/zuo.php'; // tu jest moja domena na ktorej jest skrypt
myRand = parseInt(Math.random()*999699999999999);
var modurl = myurl+"?pole1=" + document.form.pole1.value + "&pole2=" + document.form.pole2.value + "&rand=" + myRand;
http.open("GET", modurl, true);
http.onreadystatechange = function{
if (http.readyState == 4) {
if(http.status == 200) {
document.getElementById('lol').innerHTML = "zrobilem";
}
}
}
http.send(null);
}
</script>
<form name="form">
<input type="text" name="pole1" style="width: 200px;" /><br />
<textarea name="pole2" style="width: 200px; height: 100px;">
</textarea><br />
<input onClick="useHttpResponse();" type="button" value="Zapisz" />
</form>
<br>
<div id="lol"></div>
</body></html>
<script language="JavaScript" type="text/javascript">
function getXMLHTTPRequest() {
req = false;
try {
req = new XMLHttpRequest();
} catch(err1) {
try {
req = new ActiveXObject("Msxml2.XMLHTTP");
} catch (err2) {
try {
req = new ActiveXObject("Microsoft.XMLHTTP");
} catch (err3) {
req = false;
}
}
}
return req;
}
var http = getXMLHTTPRequest();
function useHttpResponse() {
var myurl = 'http://xxxx.eu/nauka/zuo.php'; // tu jest moja domena na ktorej jest skrypt
myRand = parseInt(Math.random()*999699999999999);
var modurl = myurl+"?pole1=" + document.form.pole1.value + "&pole2=" + document.form.pole2.value + "&rand=" + myRand;
http.open("GET", modurl, true);
http.onreadystatechange = function{
if (http.readyState == 4) {
if(http.status == 200) {
document.getElementById('lol').innerHTML = "zrobilem";
}
}
}
http.send(null);
}
</script>
<form name="form">
<input type="text" name="pole1" style="width: 200px;" /><br />
<textarea name="pole2" style="width: 200px; height: 100px;">
</textarea><br />
<input onClick="useHttpResponse();" type="button" value="Zapisz" />
</form>
<br>
<div id="lol"></div>
</body></html>
Plik zuo.php
<?php $dane = $pole1." ".$pole2."\n"; $file = "baza.txt"; } ?>
Pozdrawiam