Error performing actual time request with XMLHttpRequest

-1

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>&nbsp;<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 />
    
asked by anonymous 12.02.2018 / 20:01

1 answer

-1

I was checking and I came to the conclusion that the code was not wrong, the problem was to cache simply, I created a new file, copied the code of the file that was with the problem, and changed the request URL, it worked right, the tip will be there, so you have the same problem.

    
13.02.2018 / 18:07