I'm having an error in my Real Time request via XMLHttpRequest, follow the javascript code:
function requisitar() {
var base_url = window.location.origin;
var xmlhttp;
if (window.XMLHttpRequest)
{
xmlhttp = new XMLHttpRequest();
} else
{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function ()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
document.getElementById("solicitacao_mesas").innerHTML = xmlhttp.responseText;
}
}
xmlhttp.open("GET", base_url + "/modulos/lista_solicitacao_mesas.php", true);
xmlhttp.send();
}
window.setInterval(requisitar, 1000);
Now follow my PHP:
header('Cache-Control: no-cache, no-store, must-revalidate');
header('Pragma: no-cache');
header('Expires: 0');
include_once($_SERVER['DOCUMENT_ROOT'] . '/conexao/conecta.php');
$read = new Read;
$read->ExeRead("ws_notificacao");
if ($read->getResult()) {
foreach ($read->getResult() as $mesa) {
$read->ExeRead("ws_users", "where user_id = :id", "id={$mesa->user_id}");
if ($read->getResult()) {
$user = $read->getResult()[0];
}
if ($mesa->status == 0) {
echo "<audio style=\"display:none;\" autoplay=\"autoplay\" controls=\"controls\">
<source src=\"{$base}/images/alert.mp3\" type=\"audio/mp3\" />
Seu navegador não suporta HTML5
</audio>";
$btn = "<a class=\"btn btn-success btn-md btn-flat aceitar\" data-id=\"{$mesa->notificacao_id}\">Aceitar</a> <a class=\"btn btn-danger btn-md btn-flat rejeitar\" data-id=\"{$mesa->notificacao_id}\">Rejeitar</a>";
} else {
$btn = "";
}
$data = date('d/m/Y', strtotime($mesa->data));
$hora = date('H:i:s', strtotime($mesa->hora));
echo "<tr><td>{$mesa->notificacao_id}</td><td>{$mesa->mesa_id}</td><td>{$user->user_name} {$user->user_lastname}</td><td>{$data}</td><td>{$hora}</td><td>{$btn}</td></tr>";
}}
The error that is returned:
<b>Parse error</b>: syntax error, unexpected 'endif' (T_ENDIF) in <b>/app.artcomacucar.com.br/modulos/lista_solicitacao_mesas.php</b> on line <b>21</b><br />