with jQuery
Here's and example of how to do it:
post.php
Code:
<?php
echo $_POST['name'];
?>
js.js
Code:
//<![CDATA[
function rResult(data, textStatus) {
$("#results").html(data); // returns echo $_POST['name'] in the id field results
}
function post() {
var name = $("#name").val(); //get the value of the object with the id="name"
$.post("post.php", { "name": name }, rResult);
}
//]]>
index.php
Code:
<script type="text/javascript" src="http://europemafia.com/system/js/jquery.js"></script>
<script type="text/javascript" src="js.js"></script>
<div id="results"></div>
<input type="text" id="name" onkeypress="{if (event.keyCode==13)post()}" />
By the way, I would download the jquery api and not use the eurpemafia.com/system/js/jquery.js api