'Use Ajax in Fat free framework to render route every 5 seconds
I need for help in fat free
I want to use ajax to render to a specific route every 5 seconds
But I can't console any data the ajax page
and this is my php code :
elseif ($this->session->isRole(UserRole::TRAINEE)) {
$this->assets->addJs('meeting.js');
$f3->push('init.js', 'Meetings');
$f3->set('name', $name);
$f3->set('joinUrl', 'meeting/' . $meetingId);
$this->render();
}
and this is my ajax code
let Meetings = function () {
let joinMeeting = function () {
$(document).on('click', '.join-meeting', function (e) {
e.preventDefault();
let meetingId = data.meeting_id;
$.ajax({
type: 'GET',
url: '/meeting/' + meetingId,
contentType: 'application/json',
success: function (result) {
if (result.joinUrl === 'none') {
noty({text: 'Could not join the requested meeting.', type: 'error'});
} else {
setInterval(window.open(result.joinUrl, '_blank'), 5000);
}
},
error: function (jqXHR) {
noty({text: 'Application error', type: 'error'});
}
});
});
};
return {
//main function to initiate the module
init: function () {
joinMeeting();
}
}
}();
Solution 1:[1]
If you render a page, the page is loaded and the script is reloaded again and set interval is never ejecuted.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Pou |