Here is my jQuery script that sends the values of name, password, and email to register.php
and then displays a message echoed in register.php
withindiv#message
.
However, when I click the postBtn
, nothing happens and the console does not show any log of the click event.
jQuery Code:
$(document).ready(function() {
$("#btnPost").on("click", function() {
console.log('clicked');
var thisBtn = $(this);
var parent = thisBtn.parent();
name = parent.data('name');
password = parent.data('password');
email = parent.data('email');
$.post(
'register.php',
{
name: ('name'),
password: ('password'),
email: ('email')
},
function(data) {
parent.next('#message').html(data);
}
);
});
});
This section contains HTML elements for entering data, but no action seems to occur upon clicking the #postBtn
button.
<table>
<tr>
<td> Username: <td>
<td> <input type = "text" class = "field" name = "name"> </td>
</tr>
<tr>
<td> Password: <td>
<td> <input type = "password" class = "field" name = "password"> </td>
</tr>
<td > Email: <td>
<td> <input type = "email" class = "field" name = "email"> </td>
</tr>
<tr>
<td> <td>
<td> <button class='regular' id = "btnPost" name='save'> Log In </button></td>
</tr>
<tr>
</table>