What I need is to pre-load 5 results from an external page and have them in a slide like bxSlider So when the 5 results pre-load I can use bxSlider or any kind of slide to slide the next result out of the 5 pre-loaded. Then each time I click the next slide I want to remove the first pre-loaded results and add 1 to the end like using append. So in the end I want to pre-load x number of results for load time, then as I go though them remove the ones already viewed and add 1 to the current results.
Example:
<div>Pre-loaded Result1</div>
<div>Pre-loaded Result2</div>
<div>Pre-loaded Result3</div>
<div>Pre-loaded Result4</div>
<div>Pre-loaded Result5</div>
Slide
<div>New Result1</div>
<div>New Result2</div>
<div>New Result3</div>
<div>New Result4</div>
<div>New Result5</div>
So like in the example above pre-load results from external php page and as I go through them add new ones and remove the ones already seen. Thanks
Here is what I have so far the the index page:
var nextUser = 0;
var slider = $("#slider1").bxSlider();
$("#slider1")
.load("find_get.php?num="; + nextUser, function() {
nextUser++; slider.goToNextSlide(); });
<div id="slider1" class="find_outer">
Loading...
</div>
And here is what i have for the fin_get page:
$num = isset($_GET['num']) ? $_GET['num'] : exit ;
$query = "SELECT * FROM user WHERE id != '$user_id' LIMIT $num,1";
$stmt = $db -> query($query) or die (mysql_error());
while ($rows = $stmt -> fetch(PDO::FETCH_ASSOC)) {
$id = $rows['id'];
$firstname = $rows['firstname'];
$lastname = $rows['lastname'];
$display_info .= '<div class="bxdr" id="'.$id.'">' . $firstname . '
' . $lastname . '</div>';
}
echo $display_info;
This can be done easily by wrapping all child div
's under a parent div
.
<div id="ParentDiv">
<div>Pre-loaded Result1</div>
<div>Pre-loaded Result2</div>
<div>Pre-loaded Result3</div>
<div>Pre-loaded Result4</div>
<div>Pre-loaded Result5</div>
</div>
So after getting the results, you can use this $.html() to replace the contents like this
$("#ParentDiv").html(...updated slide contents here...);