html - jquery loader not appearing second time -
i calling loader till response comes server side.the problem after first run of uploading file, when uploading second time loader not coming . new jquery please me out. code snippet
<form id="myform" action="upload.php" method="post" enctype="multipart/form-data"> <input id="doc" class="file" type="file" name="xls" data-min-file-count="1"> <br> <button type="submit" class="btn btn-primary">submit</button> <button type="reset" id="asd" class="btn btn-default">reset</button> </form> <hr> <div class="panel panel-default"> <div class="panel-heading">the suggestions appear here</div> <div class="panel-body" id="output1"> <img id="loader" src="30.gif" /> </div> </div> <script> $("img#loader").hide(); $("#doc").fileinput({ 'allowedfileextensions': ['xls'], }); $(document).ready(function() { $("#asd").click(function() { $("#output1").empty(); }); var options = { target: '#output1', beforesubmit: function() { $("img#loader").show(); alert("hinnh"); }, success: function() { $("img#loader").hide(); } } $('#myform').ajaxform(options); }); </script>
you should not empty output1 div. update $("#asd").click
- function below code.
$("#asd").click(function(){ $("#output1").html('<img id="loader" src="30.gif" />'); $("img#loader").hide(); });
or
$(document).ready(function() { $("#asd").click(function() { $("#output1").empty(); }); var options = { target: '#output1', beforesubmit: function() { $("#output1").html('<img id="loader" src="30.gif" />'); alert("hinnh"); }, success: function() { $("img#loader").hide(); } } $('#myform').ajaxform(options); });
Comments
Post a Comment