Reputation: 435
I'm using jQuery Form plugin (https://github.com/malsup/form):
$("#dlgTask form").ajaxForm({
success: function(res) {
var form = this;
}
});
In success
function, form
variable seems an object other than the form itself. How to access the form, so I can avoid using $("#dlgTask form")
again for reusability? Thanks.
Upvotes: 1
Views: 10101
Reputation: 107
The success' callback function has a 4th argument for your jQuery-wrapped form element.
$("#dlgTask form").ajaxForm({
success: function(res, status, xhr, form) {
// ...
}
});
You can also simply store your form element before using ajaxForm()
var form = $("#dlgTask form");
form.ajaxForm({
success: function(res) {
// ...
}
});
Upvotes: 1