i currently have a table that loads a bunch of results via an ajax request you can see the code below. however when i try to add a loading gif i am only seeing the loading gif on the page it doesn't remove itself after the ajax request was suscessfull
i can see the page fire the ajax request and it return the data
i am chasing the loading bar to show while the ajax is processing then hide when its loaded
this is the html code
<div class='content'>
<div class='panel panel-flat' id='records_loading'>
<table class='table table-togglable table-hover table-striped' data-limit-navigation='5' data-page-size='20'>
<thead class='bg-teal'>
<tr>
<th data-toggle='true' data-type='numeric'>SMS ID</th>
<th data-hide='phone'>Time Stamp</th>
<th data-hide='phone,tablet'>Mobile Number</th>
<th data-hide='phone,tablet'>Message</th>
<th data-hide='phone,tablet'>Message Status</th>
</tr>
</thead>
<tbody id='records_table'>
</tbody>
</table>
</div>
<ul class='pagination pagination-separated hide-if-no-paging'></ul>
</div>
this is the ajax code
<script>
function showResult(str) {
$.ajax({
url: '/getjson.php?search='+str,
type: 'POST',
dataType:'json',
beforeSend:function(response)
{
$('#records_loading').html('<img src="assets/content/login.gif">');
},
success: function (response)
{
var trHTML = '';
$.each(response, function (key,value) {
trHTML +=
'<tr><td>' + value.ID +
'</td><td>' + value.Timestamp +
'</td><td>' + value.Number +
'</td><td>' + value.Message +
'</td><td>' + value.Status +
'</td></tr>';
});
$('#records_table').html(trHTML);
$('.table-togglable').trigger('footable_redraw');
}
});
}
showResult('');
</script>