<script type="text/javascript">
$(document).ready(function($){
$.supersized({
//Background image
slides : [ { image : 'images/pendulumWeb.jpg' } ]
});
$("form#submit").submit(function() {
// we want to store the values from the form input box, then send via ajax below
var email = $('#email').attr('value');
$.ajax({
type: "POST",
url: "ajax.php",
data: "email="+ email,
success: function(){
$('form#submit').hide(function() {
$('div.success').fadeIn();
});
}
});
return false;
});
});
</script>
<div id="contact">
<form id="submit" method="post">
<legend>Enter InformationEnter InformationEnter InformationEnter InformationEnter InformationEnter InformationEnter InformationEnter Information</legend>
<div id="submit">
<input id="email" name="email" value="Email Address" size="20" type="text" />
<button class="buttonPositive" type="submit">Submit</button>
</div>
</form>
<div class="success" style="display: none;">We will email you shortly.</div>
</div>
I am having a hard time figuring out why when I click my submit button why my text after my success (fadeIn) won’t appear below the submit button. I am doing a console log of test but it stops going to the console right below $('form#submit').hide(function()..Maybe I am missing something simple here? Problem fixed! Thanks Adam
One more thing! My data is not getting to my db..here is my code..I am getting a primary id of 0 but no data.
// This is config.php //
$sql = mysql_connect("localhost","root","");
if (!$sql)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("test", $sql);
//
include('config.php');
// CLIENT INFORMATION
$email = htmlspecialchars(trim($_POST['email']));
$addClient = "INSERT INTO clientEmails (Email) VALUES ('$email')";
mysql_query($addClient) or die(mysql_error());
Try removing the callback function to
hide():Also, you have a form and a div with the same id. I suggest you should change one of them, because that might be what was causing your success message not to show.
Ad@m