The GOAL:
Click of a “next slide” button refreshes / replaces <div>
content with new content from a different php file. Each slide is its own php file. This is for an online course I’m building. Each time the button is clicked the <div>
existing content is replaced by new content from the next slide (php file) in the series. I also want to build a back button to go to the previous slide, but I’m not at this point yet.
The PROBLEM:
I’m currently trying to use jquery/ajax. The button works (refreshes the <div>
with the new slide content) in the first two slides, but then does not work on the third slide. I placed the button on each slide (prefer it this way). This may be one of the problems. I thought another issue may have to do with the file path for the page variable. I'm also wondering if the problem has to do with the fact that the home page only “includes” the other files in Div’s. Like this:
<div id="header">
<?php include 'pf_header.php'; ?>
</div>
<div id="menu">
<?php include 'pf_menu.php'; ?>
</div>
<div id="content">
<?php include 'pf_welcome.php'; ?>
</div>
<div id="footer">
<?php include 'pf_footer.php'; ?>
</div>
All of my code is below:
Script.js
$(document).ready(function() {
$(".slide").on("click", function(e){
$(".content").load($(this).attr("page"));
});
});
Slide 1 (button works)
<div class="content">
<div id="main">
<input type="button" value="NEXT" id="nextbtn" class="slide" page="pf_instructions.php">
</div>
<div id="sidebar">
<div id="aside1">
<iframe src="https://www.youtube.com/embed/NAeha727ZWI"></iframe>
</div>
<div id="aside2">
</div>
</div>
</div>
Slide 2 (button works)
<div class="content">
<div id="main">
<p>INSTRUCTIONS</p>
<p>INSTRUCTIONS</p>
<input type="button" value="NEXT" id="nextbtn" class="slide" page="basics/pf_l1_introduction.php">
</div>
<div id="sidebar">
<div id="aside1">
<iframe src="https://www.youtube.com/embed/NAeha727ZWI"></iframe>
</div>
<div id="aside2">
</div>
</div>
</div>
Slide 3 (button DOES NOT work)
<div class="content">
<div id="main">
<p></p>
<input type="button" value="NEXT" id="nextbtn" class="slide" page="basics/pf_l1_quiz.php">
</div>
<div id="sidebar">
<div id="aside1">
<iframe src="https://www.youtube.com/embed/NAeha727ZWI"></iframe>
</div>
<div id="aside2">
</div>
</div>
</div>