I have file upload using jquery form plugin as
$(function() {
$("#Form").ajaxForm({
iframe: true,
dataType: "json",
url: "Upload/Index",
success: function(result) {
$('#MyGrid').append('<tr><td><a href="#">result</a></td></tr>');
},
beforeSubmit: function() {
},
error: function(response) {
alert('error');
}
});
});
and my form as
<form id="Form" method="post" enctype="multipart/form-data">
<br />
<input type="file" name="addedFile" id="addedFile" />
<br />
<input type="submit" id="submit" value="submit" runat="server" />
</form>
Now i want to show loading gif image from user clicks submit button to till i get result to success function. how can i do that .
thanks,
michaeld
You can just insert an
imgelement into the DOM (I assume this would go in thebeforeSubmitfunction):Then you can just use CSS to position it absolutely or whatever else you’d like to do.
Then, on
errororsuccess, you can remove the image:You could make it a little more efficient by only building the element once, and then simply adding/removing from the DOM, but this is a basic start.