What I need to do is submit the form with Ajax, post the form content as post data to the same page, and fade the div in when it's finished.
The problems I'm having are:
- Submit the form through ajax without refreshing
- Post the form's content to the same page
- Fade my div in once the form has been submitted
The code I currently have is:
<script src='http://code.jquery.com/jquery-1.8.2.js'></script>
<script>
$("submits").click(function() {
$('form').bind('submit', function () {
$.ajax({
type: 'post',
url: 'index.php',
data: $('form').serialize(),
success: function () {
alert('Success');
}
});
$(".element")
.css({ opacity:0, visibility:"visible" })
.animate({ opacity:1 }, "slow");
});
</script>
<?php
If(!Empty($_POST)){
?>
<div class="availability" id="availability">
<?php
Include 'functions/functions.php';
$Username = $_POST['username'];
If(Class_Exists('AIM')){ // note: this is just a check since i move my files a lot
AIM::Execute($Username);
}
?>
</div>
Without trying to catch the form submission, everything works as expected.
If you need any other code needed to be provided to help, just comment, and any help is greatly appreciated, thank you.