I have a sign-up page where I use data-steps for each step. This is working fine. However, for my own needs, I need to figure out how I am able to send the php request without refreshing the page.
To prevent refreshing in the form I have to use
<button type="button" name="register">
But how am I able to send the request to php when the button type = button. I have seen posts where people say I need to use jquery. I get that. But, how? Can anyone explain me that over here?
I want to use Jquery and this, but how do I get my form input in that data and especially how do I receive those in php?
$('#submit').click(function() {
$.ajax({
url: 'register.inc.php',
type: 'POST',
data: {
email: 'HOW DO I GET FORM INPUT HERE?',
username: 'HOW DO I GET FORM INPUT HERE?'
},
success: function(msg) {
alert('Register succesful!');
}
});
});
Thanks for the effort, already.
EDIT: I got this now:
<script>
$(function () {
$('button').bind('click', function (event) {
event.preventDefault();
$.ajax({
type: 'POST',
url: '../includes/register.inc.php',
data: $('form').serialize(),
success: function () {
alert('yoope');
}
});
});
});
</script>
Above scripts work. However, it is giving me the alert always and does not use the errors I give in the php script anymore. How to fix?