I'm looking for an implementation of a simple button to load some elements at time. Around the web, after many days of searches, i have found a lot of examples but all based on mySQL database, and nothing similar to my case. I'm wondering, is it so difficult to implement this function? Need to do this, due to better performance.
For example: When the page loads, it should load the first 9 elements of the foreach loop, after click the button, other 9, etc etc... Easy to explain, but not to do. :(
Here I have this test code, and I would like to start with this:
<?php
?>
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="https://code.jquery.com/jquery-1.8.3.min.js"></script>
<script>
$(document).ready(function() {
$("#loadmore").click(function(e) {
$.ajax({
type: 'POST',
data: { // },
cache: false,
success: function(test) {
// What need to do here?
}
error: function(err){
alert("Error!");
}
});
e.preventDefault();
});
});
</script>
</head>
<body>
<?php
$db_txt = "dblinks.txt";
$dblines = file($db_txt);
foreach($dblines as $key => $links) {
echo $links."<br>\n";
}
?>
<input type="button" id="loadmore" value="Show More" />
</body>
</html>
For my basic knowledge about php, jquery, ajax, i need your help. Please. Thanks a lot.