dsgsgs30201 2018-11-19 05:36
浏览 79

PHP FullCalendar不显示事件

I´m using the Fullcalendar framework for a web application, the problem is that, when consulting, I get an empty JSON, like this: [ ]

From Google Chrome

I don´t know if it has anything to do with that, but at this moment I´m using a host called Hostinger, what´s weird is that when executing the code in XAMPP it works correctly

In xampp

I´m uploading the view calendario.php from CodeIgniter and collecting info from eventosc.php, which is not inside the folders of this framework

Where should I start looking?

views/calendario.php

Here i make de AJAX call to eventosc.php

    <!DOCTYPE html>
    <html lang="es">
    <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Eventos</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
    <script src="<?php echo base_url();?>js/jquery.min.js"></script>
    <script src="<?php echo base_url();?>js/moment.min.js"></script>
    <!-- FullCalendar -->
    <link rel="stylesheet" href="<?php echo base_url();?>css/fullcalendar.min.css">
    <script src="<?php echo base_url();?>js/fullcalendar.min.js"></script>
    <script src="<?php echo base_url();?>js/es.js"></script>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-cs/chFZiN24E4KMATLdqdvsezGxaGsi4hLGOzlXwp5UZB1LY//20VyM2taTB4QvJ" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js" integrity="sha384-uefMccjFJAIv6A+rW+L4AHf99KvxDjWSu1z9VI8SKNVmz4sk7buKt/6v9KI65qnm" crossorigin="anonymous"></script>

    </head>

     <style>
    footer div a{
        text-align: center;
        text-decoration: none;
        transition: 0.5s;
     }
     footer div a:hover
     {

     text-decoration: none;
     text-align: center;
     transition: 0.5s;
     color: #000000; 
     }
     </style>
     <body>

     <div class="container" style="margin-top:30px;">
        <div class="row">
            <div class="col"></div>
            <div class="col-md-7"><div id="CalendarioWeb"></div></div>
            <div class="col"></div>
        </div>
     </div>

     <script>
        $(document).ready(function(){
            $('#CalendarioWeb').fullCalendar({
                header:{
                    left:'today,prev,next',
                    center:'title',
                    right:'month, basicWeek, basicDay, agendaWeek, agendaDay'
                },
                dayClick:function(date,jsEvent,view){
                    limpiarFormulario();
                    $('#txtFecha').val(date.format());
                    $("#ModalEventos").modal();
                },

                events:'/fullc/eventosc.php',

                eventClick:function(calEvent,jsEvent,view){
                    //H2
                    $('#tituloEvento').html(calEvent.title);
                    //MOSTRAR LA INFORMACION DEL EVENTO EN LOS INPUTS
                    $('#txtDescripcion').val(calEvent.descripcion);
                    $('#txtId').val(calEvent.Id);
                    $('#txtTitulo').val(calEvent.title);
                    $('#txtColor').val(calEvent.color);

                    FechaHora= calEvent.start._i.split(" ");
                    $('#txtFecha').val(FechaHora[0]);
                    $('#txtHora').val(FechaHora[1]);

                    $("#ModalEventos").modal();


                },
                editable:true,
                eventDrop:function(calEvent){
                    $('#txtId').val(calEvent.Id);
                    $('#txtTitulo').val(calEvent.title);
                    $('#txtColor').val(calEvent.color);
                    $('#txtDescripcion').val(calEvent.descripcion);

                    var fechaHora=calEvent.start.format().split("T");
                    $('#txtFecha').val(fechaHora[0]);
                    $('#txtHora').val(fechaHora[1]);

                    RecolectarDatosGUI();
                    EnviarInformacion('modificar',NuevoEvento,true);


                }
            });
        });   
      </script>


 <!-- Modal (AGREGA, QUITA, MODIFICA)-->
 <div class=

"modal fade" id="ModalEventos" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
    <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="tituloEvento"></h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
          <input type="hidden" id="txtId" name="txtId" />
          <input type="hidden" id="txtFecha" name="txtFecha" />

        <div class="form-row">
            <div class="form-group col-md-8">
                <label>Titulo del Evento: </label>
                <input type="text" id="txtTitulo" name="txtTitulo" class="form-control" placeholder="Titulo del Evento" />
            </div>
            <div class="form-group col-md-4">
                <label>Hora del Evento:</label>
                <input type="text" id="txtHora" name="txtHora" class="form-control" value="10:30"/>
            </div>
        </div>

        <div class="form-group">
            <label>Descripcion:</label>
            <textarea id="txtDescripcion" rows="3" class="form-control"></textarea><br/>
        </div>
        <div class="form-group">
            <label>Color:</label>
            <input type="color" id="txtColor"  name="txtColor" class="form-control" style="height:36px;"/>
        </div>

      </div>
      <div class="modal-footer">
        <button type="button" id="btnAgregar" class="btn btn-success" >Agregar</button>
        <button type="button" id="btnModificar" class="btn btn-secondary">Modificar</button>
        <button type="button" id="btnBorrar" class="btn btn-danger">Borrar</button>
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancelar </button>
      </div>
    </div>
  </div>
</div>

 <footer class="row">
         <div class="col">
          <a href="<?php echo base_url();?>index.php/portalc/portal" style="text-decoration:none" > <h4>Regresar</h4></a>
         </div>
       </footer>

<script>
var NuevoEvento;
    $('#btnAgregar').click(function(){
        RecolectarDatosGUI();

        EnviarInformacion('agregar',NuevoEvento);

        //alert (NuevoEvento);
    });

    $('#btnBorrar').click(function(){
        RecolectarDatosGUI();

        EnviarInformacion('eliminar',NuevoEvento);

        //alert (NuevoEvento);
    });

     $('#btnModificar').click(function(){
        RecolectarDatosGUI();

        EnviarInformacion('modificar',NuevoEvento);

        //alert (NuevoEvento);
    });

function RecolectarDatosGUI(){
var id = $('#txtId').val();
var titulo = $('#txtTitulo').val();
var start = $('#txtFecha').val()+" "+$('#txtHora').val();
var color = $('#txtColor').val();
var descripcion= $('#txtDescripcion').val();
var end = $('#txtFecha').val()+" "+$('#txtHora').val();
//alert(titulo);

    NuevoEvento={
            id1:id,
            title1:titulo,
            start1:start,
            color1:color,
            descripcion1:descripcion,
            textColor1:"#FFFFFF",
            end1:end
        };
        //alert(JSON.stringify(NuevoEvento));
}
function EnviarInformacion(accion,objEvento,modal){
    // alert(JSON.stringify(objEvento));
    $.ajax({
        type:'POST',
        url:'/fullc/eventosc.php?accion='+accion,
        data:objEvento,
        success:function(msg)
        {
            if(msg){
                $('#CalendarioWeb').fullCalendar('refetchEvents');
                if(!modal){
                    $("#ModalEventos").modal('toggle');
                }
            }
        },
        error : function(){
            alert("error");
        }
    });
}
function limpiarFormulario(){
    $('#txtId').val('');
    $('#txtTitulo').val('');
    $('#txtColor').val('');
    $('#txtDescripcion').val('');
}
</script>
</body>
</html>

fullc/eventosc

the default case is always working in XAMPP

<?php 
header('Content-Type: application/json');

    $pdo=new PDO("mysql:dbname=bd;host=localhost","user","pass");
    $pdo->exec("set names utf8");

$accion=(isset($_GET['accion']))?$_GET['accion']:'leer';
    switch($accion){
        case 'agregar':
        $sentenciaSQL = $pdo->prepare("INSERT INTO Eventos(title, descripcion, color, textColor, start, end) VALUES (:title2,:descripcion2,:color2,:textColor2,:start2,:end2)");

        $respuesta=$sentenciaSQL->execute(array(
            "title2"=>$_POST['title1'],
            "descripcion2"=>$_POST['descripcion1'],
            "color2"=>$_POST['color1'],
            "textColor2"=>$_POST['textColor1'],
            "start2"=>$_POST['start1'],
            "end2"=>$_POST['end1']
        ));
        echo json_encode($respuesta);
        break;

        case 'eliminar':
        $respuesta=false;
        if(isset($_POST['id1'])){
            $sentenciaSQL= $pdo->prepare("DELETE FROM Eventos WHERE Id = :ID");
            $respuesta=$sentenciaSQL->execute(array("ID"=>$_POST['id1']));
        }
        echo json_encode($respuesta);

        break;

        case 'modificar':

            $sentenciaSQL = $pdo->prepare("UPDATE Eventos SET 
            title=:title,
            descripcion=:descripcion,
            color=:color,
            textColor=:textColor,
            start=:start,
            end=:end 
            WHERE Id=:ID");

            $respuesta=$sentenciaSQL->execute(array(
                "ID"=>$_POST['id1'],
                "title"=>$_POST['title1'],
                "descripcion"=>$_POST['descripcion1'],
                "color"=>$_POST['color1'],
                "textColor"=>$_POST['textColor1'],
                "start"=>$_POST['start1'],
                "end"=>$_POST['end1']
            ));
            echo json_encode($respuesta);
        break;

        default:
            //Seleccionar los eventos del calendario
            $sentenciaSQL= $pdo->prepare("SELECT * FROM Eventos");
            $sentenciaSQL->execute();

            if(!$sentenciaSQL){
                echo 'error';
            }
            else{
                $resultado=$sentenciaSQL->fetchAll(PDO::FETCH_ASSOC);
                echo json_encode ($resultado);
            }    

        break;
    }
?>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 如何在scanpy上做差异基因和通路富集?
    • ¥20 关于#硬件工程#的问题,请各位专家解答!
    • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 截图中的mathematics程序转换成matlab
    • ¥15 动力学代码报错,维度不匹配
    • ¥15 Power query添加列问题
    • ¥50 Kubernetes&Fission&Eleasticsearch
    • ¥15 報錯:Person is not mapped,如何解決?
    • ¥15 c++头文件不能识别CDialog