[jQuery] Form Ajax and PHP

[jQuery] Form Ajax and PHP

Hi all,
I want to save data typed into a form in to a simple file
with a script file write in PHP.
I must use $.ajax or $.post? Well, both don't work for me, sure
I'm in error but where?
index.htm
<MyHtmlCode>
<html>
<head>
<title> jquery </title>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#myForm").submit(function(){
var testoForm = $("input[@name=testo]").val();
/* With this code don't work */
$.ajax({
    type: "POST",
    url: "script.php",
    data: "ValoreForm="+testoForm,
    success: function(){$("#output").html("Written data with success!");}
});
/* The same with this code */
$.post("script.php");
});
});
</script>
</head>
<body>
<form id="myForm" method="post">
<input type="text" name="testo">
<input type="submit" name="submit" value="salva">
</form>
<div id="output">Ajax response will replace this content.</div>
</body>
</html>
</MyHtmlCode>
This is a stupid PHP code which I verify if the script go in function
creating a txt file with a simple text inside
// script.php
<MyPHPCode>
<?php
$f = "db.txt";
$t = "Hello JQuery!";
$fh = fopen($f, 'wa') or die("Error!!!");
fwrite($fh,$t);
fclose($fh);
?>
</MyPHPCode>
--
Massimiliano Marini - http://www.linuxtime.it/massimilianomarini/
"It's easier to invent the future than to predict it." -- Alan Kay
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/