the error of the title already comes to me when it is accessible from the outside, that is to say when it is already "open" to the public, but obviously I have it as hidden; Someone would know the origin of the error since it gives me error in the line 397 and the line 398 of a JavaScript code here is the code
function refrescar_mensajes_N_v(){
return new Promise(resolve => {
setInterval(
function() {
var notifica = true;
request = $.ajax({
url: ".refresh_n_v.php",
type : "POST",
data : notifica,
success: function (response) {
response = JSON.parse(response);
//console.log($.isEmptyObject(response) );
if($.isEmptyObject(response)==false){
for(var i in response){
$('#mi_panel').html(
$('<div/>', {'class':'panel panel-primary','id':'mensaje_'+response[i].id}).append(
$('<div/>',{'class':'panel-heading','html':'Mensaje Nuevo! - '+response[i].fecha}),
$('<div/>', {'class':'panel-body'}).html(response[i].mensaje),
$('<div/>',{'class':'panel-body'}).append($('<button/>',{'type':'button','class':'btn btn-success','onclick':'dejar_visto('+response[i].id+')','html':'OK'}))));
}
}else{
// $('#mi_panel').replaceWith('<h3 id="no_mensajes">No tienes Mensajes nuevos</h3>');
}
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(xhr.status);
console.log(thrownError);
}
});
}, 60000);
});
}
I'll be sorry for the lack of tabbing, copy + paste in this medium makes me a little troll, the call to this function is in a $ (document) .ready and it runs every minute to see if you have new messages or not and in turn you can leave the message in seen, the error comes out in the two console.log , and I do not understand the cause, since it is local works .
Where I do the POST I have this:
<?php
include ('includes/sesion.inc.php');
$nivel[]=1;
$nivel[]=2;
controlar_acceso_permitido($nivel);
$lista_mensajes = lista_mensajes('',$conn);
$listado = [];
$usuario_log = $_SESSION['grieo_1_000']['usuario'];
//var_dump($lista_mensajes['count']);
for ($i=0; $i < $lista_mensajes['count']; $i++) {
if ($lista_mensajes[$i]['accion']=='NO_VISTO' && $usuario_log['id'] == $lista_mensajes[$i]['id_usuario']) {
$listado[] = array(
'id' => $lista_mensajes[$i]['id'],
'fecha' => $lista_mensajes[$i]['fecha'],
'mensaje' => $lista_mensajes[$i]['mensaje'],
'accion' => $lista_mensajes[$i]['accion'],
'estado' => $lista_mensajes[$i]['estado'],
'status' => $lista_mensajes[$i]['status'] );
}
}
echo json_encode($listado, JSON_FORCE_OBJECT);
?>
is to make a query to the database, pick them up and save them to an Array that I later turn it into JSON format, it does not have more complexity.
Thanks for your attention and hopefully you can help me :)
UPDATE:
I have been careful to add that I have a very similar code which only collects a number and shows these functions are executed asynchronously, I think, the fact is that if I do not execute this code, but if I execute the above, the error is there the code of ahroa does not work as much in local as in the previous one where I ask the question no.
function refresca_notificaciones(){
return new Promise(resolve => {
setInterval(
function() {
var notifica = true;
var respuesta = []
//console.log("HOLA KE ASE");
request = $.ajax({
url: ".refresh_num_no_vistos.php",
type : "POST",
data : notifica,
success: function (response) {
if(response != 0){
$('#n_visto').removeClass('oculta').html(response);
}else{
$('#n_visto').addClass('oculta');
}
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(xhr.status);
console.log(thrownError);
}
});
}, 60000);
});