Let's say we have a code like this:
<script type="text/javascript">
$(document).ready(function() {
$("#signup").click(function(e) {
e.preventDefault();
var email = $("#email").val();
var fname = $("#fname").val();
$.post("signup.php", {email:email, fname:fname}, function(data) {
$("#result").html(data);
});
return false;
});
});
</script>
After clicking the submit button, we can get an error message if the fields are not properly filled, in that case, the form can still retain the values, but if "submission successful" message was returned, how do I conditionally reset the form fields