I have a search bar, by default it's loading all the data under the search bar. I want to limit the default before searching to be only 5 results in the table.
I'm trying this but it doesn't work! What I'm doing wrong?
<script>
$(document).ready(function(){
load_data();
function load_data(query)
{
$.ajax({
url:"fetch.php",
method:"post",
data:{query:query},
success:function(data)
{
$('#result').html(data);
}
});
}
$('#search_text').keyup(function(){
var search = $(this).val();
if(search != '')
{
load_data(search);
$('#result').dataTable({'iDisplayLength': 5});
}
else
{
load_data();
}
});
});
</script>
And the HTML part is just this code:
<div id="result"></div>