I am working on this project and i want to update the database after being clicked on the signUp button, but the $.post() is not working and i can't find any error as no error is even being shown in the firebug of the firefox, Please help me out, I'm stuck since last night on this.
Am I doing any mistake, then please help me out to find those ?
Here is my code,
part of my script.js
.............
.............
$('#submit').click(function() {
$.post("signup.php", function(data) {
response = jQuery.parseJSON(data);
alert(response.done);
});
});
signup.php
<?php
$json = array("done" => "1");
echo json_encode($json);
?>
registration.php page
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"
..........
..........
<input type="submit" class="btn btn-lg btn-info searchBtn signUpBtn wobble-skew" value="Sign Up" name="submit" id="submit">
</form>
In the js file i was alert to just checking whether post is responding or not, it it did then i have to pass the input's value using JSON
You need to disable the normal form submission:
$('#submit').click(function(e) {
e.preventDefault(); // Prevent normal submission
$.post("signup.php", function(data) {
response = jQuery.parseJSON(data);
alert(response.done);
});
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.