i have a page with many forms, 1 in each table row. i want to submit the form, get the ajax response and then show a green checkmark or red x to indicate success or failure (without reloading the page).
how do i select the .file-success
or .file-error
span only in the form that was submitted?
<form method="POST" action="#" class="fileform">
<tr>
<td class="vert-align"><input type="text" name="name" id="name" /></td>
<td class="vert-align"><button class="btn btn-primary btn-xs" type="submit">Update</button>
<div class="feedback-icons">
<span class="file-success"><i class="fa fa-check-circle"></i></span>
<span class="file-error"><i class="fa fa-times-circle"></i></span>
</div>
</td>
</tr>
</form>
... many more forms like this in table rows
$(this).find(".file-success");
doesn't find it with or without setting the context to e.target.
$(".fileform").submit(function(e)
{
var postData = $(this).serializeArray();
var formURL = $(this).attr("action");
$.ajax(
{
url : formURL,
type: "POST",
data : postData,
context: e.target,
success:function(data, textStatus, jqXHR)
{
$(this).find('.file-success').fadeIn(500);
},
error: function(jqXHR, textStatus, errorThrown)
{
$('.file-error').fadeIn(500);
}
});
e.preventDefault();
});
thank you!