I was attemping to Insert data into the database in portions and return the results in portions. Attempted this by putting the request in a while loop and appending the results. Didn't know if there was a better way but i thought i'd try this.
HTML
<button class="id = "start"><span>Start</span> </button>
<tbody id = "results">
<!-- Table Data -->
</tbody>
JS
Couldn't get this to work not sure why i'm not familiar with javascript.
$(document).ready(function(){
$("#start").click(function(){
var start = 0;
var stop = 10;
var limit = start + ',' + stop;
while(results == 10){
$.ajax({
url: "embed.php",
type: "get",
datatype : "json",
data:{ limit: limit } ,
success : function(data)
{
$("#results").prepend(data);
start = start + 10;
}, error : function(data)
{
console.log('error');
}
});
}
});
});
Decleared var results = 10; in a script tag in header.
PHP
Calls the function that performs the query and returns an array of success messages.
<?php
$limit = filter_var($_REQUEST["limit"], FILTER_SANITIZE_STRING);
$results = $insertData->insertMovies($limit);
$i = 1;
foreach($result as $item){?>
<tr ><td><?php echo $item; $i++;?></td></tr >
<?php }?>
<script>results = <?php echo $i;?>;</script>