I’m having troubles trying to clear all fields from a form after Ajax success.
Here is the code:
$.ajax({
type: "POST",
url: "form.php",
data: datos,
success: function() {
$('#nombre, #apellidos, #telefono, #asunto, #consulta, #email').val('')
},
error: function() {}
});
It works except clearing the fields on the form. I get the mail but isn’t clearing the fields of the form.
Any ideas?
Can you verify that the IDs are assigned to the form fields? Example:
<input id="email" />