php - How to clear an ajax form after submit? -
the next ajax markup processing form:
$.ajax({ datatype: "json", type: "get", url: "ajax.php?action=add_driver", data: $("#adddriver").serialize(), beforesend: function(){ $('.error, .success, .notice').remove(); }, success: function(json){ if (json['status']=='success') { alert(json['message']); $("#adddriver").reset(); }else{ if(json['error']['my_variable']){ $("input[name=my_variable]").after('<div class="error">'+json['error']['my_variable']+'</div>'); } $("#adddriver").reset(); } });
what want know is, how clear form, 1 time has been submitted? tired using $("#adddriver").reset();
clears form without submitting form. help?
well, it's not question of how?
, in case, of when?
.
$("#adddriver")[0].reset();
should fine, provided id of form, long utilize within success()
or complete()
callback function.
php jquery ajax forms submit
No comments:
Post a Comment