Hi
I recently delved into the world of AJAX, but can't seem to get it working!
The actual displaying of a message in a div without loading is working; but there's something incorrect in my definition of fields.
I am using JQuery; with this javascript
:
Code:
<script type="text/javascript">
function request(){
$.ajax({
type: "POST",
url: "insert2.php",
data: "username=" + $("#username").value,
success: function(html){
$("#response").html(html);
}
});
}
</script>
and then the form is thus:
Code:
<form method="post" action="">
<table class="formRegistration">
<tr>
<td>Username:</td>
<td><input name="username" id="username" type="text" value="" maxlength="20" /></td>
</tr>
<tr>
<td></td>
<td><input type="button" name="submit" value="Insert" onclick="request()" /></td>
</tr>
</table>
</form>
<div id="response">
<!-- Null-->
</div>
insert2.php is simply:
PHP Code:
echo $_POST['username'];
Whenever I press Insert, it comes up with just "undefined" in the response div.
A live version is running here:
SUI Mock Up
Any help would be greatly appreciated :)