hmmm nie do konca wiem jak ma to działać:
spojrz:
formularz:
<form action="index.php" method="post"> <input type="text" id="title" name="title" size="20" /><br/> <input type="button" name="Dodaj" value="Dodaj" onclick="dodaj()" /><br/>
JS/AJAX
<script type="text/javascript"> var xmlhttp;
function init ()
{
xmlhttp = new XMLHttpRequest();
}
function dodaj ()
{
var title = document.getElementById("title").value;
var tresc = document.getElementById("text").value;
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
document.getElementById("zbiornik").innerHTML = xmlhttp.responseText + document.getElementById("zbiornik").innerHTML;
}
}
xmlhttp.open ("POST","add.php");
xmlhttp.send ();
}
plik add.php
<?php
//dodawanie do bazy mysql
?>
<div class="item">
<div id="tytul">
<?php echo $_POST["t"]; ?></div>
<div id="tresc">
<?php echo $_POST["te"]; ?></div>
</div>
<?php
?>
i nie działa to tak jak trzeba... tablica $_POST jest pusta.