John Davidson

javascript - jQuery Roadmap - Cannot determine event using PHP

0 comments
Message:


I'm using jQuery Roadmap in my project and I need to fetch the events from the database. I have a SQL statement that can fetch the date and content I want but I am facing some errors that I don't understand. This is my code:


php


while($row = mysqli_fetch_array($result)){
$date = $row["date"];
$status = $row["status"];

echo "<script>
var events = [
{
date: $date,
content: $status
}
];</script>";
}

js


<script type="text/javascript">
$(document).ready(function(){

$('#my-roadmap').roadmap(events, {
eventsPerSlide: 4,
slide: 1,
prevArrow: '<i class="fa fa-chevron-left"></i>',
nextArrow: '<i class="fa fa-chevron-right"></i>'
});
});
</script>

error:



My Answer:
'date'];
$content = $row['content'];
echo "
$content
";
}_javascript_$(document).ready(function() {
$('.roadmap').roadmap();
$('.event').click(function() {
var date = $(this).data('date');
$.ajax({
url: 'fetch_event.php',
type: 'POST',
data: {date: date},
success: function(response) {
console.log(response);
}
});
});
});_fetch_event.php_ $date = $_POST['date'];
// Fetch event from database using $date
// Return event data as JSON
echo json_encode($event_data);
?>_I am not able to determine the event when I click on it. Can someone help me with this issue?

Rate this post

4 of 5 based on 6446 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us